zoukankan      html  css  js  c++  java
  • 用NPOI导出Excel

    用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(0);
    
                HSSFCell cell1 = (HSSFCell)row.CreateCell(0, HSSFCell.ENCODING_COMPRESSED_UNICODE);
                cell1.SetCellValue("Hello");
    
                HSSFCell cell2 = (HSSFCell)row.CreateCell(1, HSSFCell.ENCODING_COMPRESSED_UNICODE);
                cell2.SetCellValue(3.14);
    
                workbook.Write(context.Response.OutputStream);
            }
    View Code
  • 相关阅读:
    基本排序
    mysql安装
    函数和方法
    COOKIE 与 SESSION
    django---入门
    django模板继承
    2017-11-14
    Django---模板层(template)
    Dajngo---model基础
    Django--基础篇
  • 原文地址:https://www.cnblogs.com/easy5weikai/p/3526993.html
Copyright © 2011-2022 走看看