用NPOI导出Excel

        public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/x-excel";
//context.Response.ContentType = "application/octet-stream"; string fileName = HttpUtility.UrlEncode("动态数据库.xls");
context.Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName); HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = (HSSFSheet) workbook.CreateSheet();
HSSFRow row = (HSSFRow)sheet.CreateRow(); HSSFCell cell1 = (HSSFCell)row.CreateCell(, HSSFCell.ENCODING_COMPRESSED_UNICODE);
cell1.SetCellValue("Hello"); HSSFCell cell2 = (HSSFCell)row.CreateCell(, HSSFCell.ENCODING_COMPRESSED_UNICODE);
cell2.SetCellValue(3.14); workbook.Write(context.Response.OutputStream);
}
05-11 03:21