Excel 출력

NativeExcel

참조 사이트 

http://www.nika-soft.com/dwnld.htm  

IWorkbook book = Factory.CreateWorkbook();

lWorksheet sheet =book.worksheets.add();

sheet.clls[1.1].value ="赋值";

sheet.Cells[1, 1, 1, 24].Interior.Color = ColorTranslator.FromHtml("#C1CDC1");
sheet.Cells[1, 1, 1, 24].RowHeight = 20;
sheet.Cells[1, 1, 1, 24].HorizontalAlignment = XlHAlign.xlHAlignCenter;
sheet.Cells[1, 1, 1, 24].VerticalAlignment = XlVAlign.xlVAlignCenter;

 处理数据

sheet.Range[1, 1, count, 24].Borders[XlBordersIndex.xlInsideAll].Weight = XlBorderWeight.xlThin;
sheet.Range[1, 1, count, 24].Borders[XlBordersIndex.xlAround].Weight = XlBorderWeight.xlThin;

FileResult fr = null;
using (System.IO.MemoryStream _MS = new System.IO.MemoryStream())
{
book .SaveAs(_MS);
fr = base.File(new System.IO.MemoryStream(_MS.ToArray()), "application/excel", "fileName.xls");
}

Response.HeaderEncoding = System.Text.UnicodeEncoding.UTF8;
Response.Charset = Response.HeaderEncoding.WebName;

return _fr;

原文地址:https://www.cnblogs.com/ok519/p/6362487.html