zoukankan      html  css  js  c++  java
  • NPOI导出自动换行效果

    string filename = "test.xls";
                Response.ContentType = "application/vnd.ms-excel";
                Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", filename));
                Response.Clear();
                string reuslt = "0.8锌铁板制做烤漆字、食人鱼防水LED模组(三颗灯)、4mm厚黑白板(特殊材料,白天黑色,打灯后发白光) ";
                int splitnum = 25;
                int num = reuslt.Length;
                int rownum = num / splitnum + ((num % splitnum) > 0 ? 1 : 0);
                HSSFWorkbook workbook = new HSSFWorkbook();
                HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet();
                int rowIndex = 0;
                int cellIndex = 0;
                HSSFRow row = (HSSFRow)sheet.CreateRow(rowIndex);
                row.HeightInPoints = rownum * 17;
                HSSFCell cell = (HSSFCell)row.CreateCell(cellIndex);
                HSSFCellStyle style = (HSSFCellStyle)workbook.CreateCellStyle();
                style.WrapText = true;
                string modify = "";
                for (int i = 0; i < rownum; i++)
                {
                    int start = splitnum * i;
                    int leave = num%(num - start);
                    modify+=(reuslt.Substring(start, leave == 0 ? splitnum : leave + 1) + "
    ");
                }
                cell.CellStyle = style;
                cell.SetCellValue(modify.TrimEnd('
    '));
                MemoryStream file = new MemoryStream();
                workbook.Write(file);
                file.WriteTo(Response.OutputStream);
                Response.End();
  • 相关阅读:
    NC105 二分查找
    Spark-Streaming总结
    spark java API 实现二次排序
    在eclipse上安装Scala插件
    maven:missing artifact jdk.tools:jar:1.7
    使用 Hive装载数据的几种方式
    Eclipse debug 调试快捷键
    yarn工作流程
    Windows 7 下安装mysql-5.7.18-winx64.zip
    希尔排序
  • 原文地址:https://www.cnblogs.com/youhaoxinqin/p/4143259.html
Copyright © 2011-2022 走看看