using (var package = new ExcelPackage()) { var workbook = package.Workbook; //*** Sheet 1 var worksheet = workbook.Worksheets.Add("Sheet1"); worksheet.Cells["A1"].Value = "ThaiCreate.Com"; worksheet.Cells["A1"].Style.Font.Bold = true; worksheet.Cells["A1"].Style.Font.Color.SetColor(System.Drawing.Color.Red); worksheet.Cells["B3"].Value = "2017"; worksheet.Cells["B3"].Style.Font.Size = 20; worksheet.Column(5).Width = 50; worksheet.Cells["E5"].Value = "New Member"; worksheet.Cells["E5"].Style.Font.Size = 12; worksheet.Cells["E5"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Right; using (ExcelRange range = worksheet.Cells["A8:E9"]) { range.Merge = true; range.Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Medium, System.Drawing.Color.Black); range.Value = "Sawatdee ThaiCreate.Com"; range.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; range.Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center; range.Style.Border.Top.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin; range.Style.Border.Left.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin; range.Style.Border.Right.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin; range.Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin; } package.SaveAs(new FileInfo(Server.MapPath(@"Xls/myExcel.xlsx"))); }
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท