excelRW.ashx 945 B

12345678910111213141516171819202122232425262728293031323334
  1. <%@ WebHandler Language="C#" Class="excelRW" %>
  2. using System;
  3. using System.Web;
  4. using NPOI.SS.UserModel;
  5. using System.Collections.Generic;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. public class excelRW : IHttpHandler
  10. {
  11. public void ProcessRequest(HttpContext context)
  12. {
  13. context.Response.ContentType = "text/html";
  14. ExcelFile excel = new ExcelFile("template.xls");
  15. excel.GetWorkbook.GetSheet("封面").GetRow(14).GetCell(6).SetCellValue("东科商标");
  16. excel.GetWorkbook.GetSheet("内容").GetRow(1).GetCell(15).SetCellValue("东科检验项目");
  17. excel.GetWorkbook.GetSheet("内容").GetRow(1).GetCell(23).SetCellValue("东科检验结果");
  18. excel.SaveAs("export.xls");
  19. context.Response.Write("文件写入成功!<a href='export.xls'>点击下载</a>");
  20. }
  21. public bool IsReusable
  22. {
  23. get
  24. {
  25. return false;
  26. }
  27. }
  28. }