这几天碰到一个需求就是导出到Excel文件
用到Aspose
//Create a workbook object Workbook workbook = new Workbook(path); //Get the first worksheet in the workbook Worksheet worksheet = workbook.Worksheets[0]; //Get the cells collection in the sheet Cells cells = worksheet.Cells; //Put a string value into the cell using its name cells["A1"].PutValue("Cell Value"); //put a string value into the cell using its name cells["A2"].PutValue("Hello World");
////Save file and send to client browser using selected format workbook.Save(HttpContext.Current.Response, "HelloWorld.xls", ContentDisposition.Attachment, new XlsSaveOptions(SaveFormat.Excel97To2003)); //end response to avoid unneeded html HttpContext.Current.Response.End();