--------导出Excel-----------使用NPOI格式输出
HttpContext.Current.Response.ContentType = "application/x-excel";//返回类型
string filename = HttpUtility.UrlEncode("导出Excel.xls"); //设置中文转换
HttpContext.Current.Response.AddHeader("Content-Disposition", //调用下载"attachment;filename=" + filename);
HSSFWorkbook work = new HSSFWorkbook(); //new出一个新的Excel文档
HSSFSheet sheet = work.CreateSheet(); //work创建一个新页面
HSSFRow rows = sheet.CreateRow(0); //sheet在这个页面新建第一个行
HSSFCell cell1 = rows.CreateCell(0,HSSFCell.CELL_TYPE_STRING);//在行里创建第一个格
cell1.SetCellValue("HELLO"); //给第一个赋值
HSSFCell cell2 = rows.CreateCell(1,HSSFCell.CELL_TYPE_STRING);//创建多一行
cell2.SetCellValue(HttpContext.Current.Request.UserHostAddress);
work.Write(HttpContext.Current.Response.OutputStream); //写回流