using OfficeOpenXml; using OfficeOpenXml.Drawing; using OfficeOpenXml.Drawing.Chart; using OfficeOpenXml.Style;
using (ExcelPackage package = new ExcelPackage()) { }
var worksheet = package.Workbook.Worksheets.Add(“sheet1");
worksheet.Cells[int row, int col].Value = “”; 或者 worksheet.Cells["A1"].Value = “”;
worksheet.Cells[int fromRow, fromCol, int toRow,int toCol].Merge = true;
var rangeData= worksheet.Cells[fromRow, fromCol, toRow, toCol];
worksheet.Cells.Style.Font.Name= “正楷”;
worksheet.Cells.Style.Font.Color
worksheet.Cells.Style.Font.Size
worksheet.Cells.Style.Border.Left.Style= ExcelBorderStyle.Thin ; worksheet.Cells.Style.Border.Right.Style= ExcelBorderStyle.Thin; worksheet.Cells.Style.Border.Top.Style= ExcelBorderStyle.Thin; worksheet.Cells.Style.Border.Bottom.Style= ExcelBorderStyle.Thin;
worksheet.Cells.Style.HorizontalAlignment=ExcelHorizontalAlignment.Center;
worksheet.Cells.Style.VerticalAlignment = ExcelVerticalAlignment.Bottom;
worksheet.Cells.Style.Fill.PatternType= ExcelFillStyle.Solid;
worksheet.Cells.Style.Fill.BackgroundColor.SetColor(Color.LightBlue);
worksheet.Cells.Style.WrapText= true;
worksheet.Cells.Style.ShrinkToFit= true;
worksheet.Cells.Style.Numberformat.Format= "0.00";
worksheet.Cells["A1"].Style.Locked= true;
var chart = (worksheet.Drawings.AddChart("LineChart", eChartType.Line) as ExcelLineChart);
原文:http://www.cnblogs.com/liudeyun/p/3535740.html