1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
XSSFWorkbook workbook = new XSSFWorkbook(); //创建工作簿 XSSFSheet sheet = (XSSFSheet)workbook.CreateSheet("test"); //创建表单 XSSFRow headerRow = (XSSFRow)sheet.CreateRow(); //创建row headerRow.CreateCell().SetCellValue(); headerRow.CreateCell().SetCellValue(); using (MemoryStream ms = new MemoryStream()) { workbook.Write(ms); ms.Flush(); //Response.Write(ms); Response.BinaryWrite(ms.ToArray()); Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); Response.AppendHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("test", System.Text.Encoding.UTF8) + ".xlsx"); Response.End(); } |
from:https://www.bbsmax.com/A/xl56OW01dr/