zoukankan      html  css  js  c++  java
  • NPOI内存溢出

    int rowIndex = 1;               // Starting Row (0 = Header)
    int sheetIndex = 1;             // Starting sheet is always set to "Sheet1"
    const int maxRows = 65536;      // Max rows p/sheet in Excel 2003
    
    // Start loop of details to write to sheet
    foreach (DataRow row in DataTableToExport.Rows)
    {
        // Check if max rows hit, if so start new sheet and copy headers from current sheet.
        if(rowIndex % maxRows == 0)
        {
            // Auto size columns on current sheet
            for (int h = 0; h < headerRow.LastCellNum; h++)
            {
                sheet.AutoSizeColumn(h);
            }
    
            // Increment sheet counter
            sheetIndex++;
    
            // Create new sheet
            sheet = workbook.CreateSheet("Sheet" + sheetIndex);
    
            // Create header on new sheet
            HSSFRow additionalHeaderRow = sheet.CreateRow(0);
    
            // Copy headers from first sheet
            for (int h = 0; h < headerRow.LastCellNum; h++)
            {
                HSSFCell additionalHeaderColumn = additionalHeaderRow.CreateCell(h);
                additionalHeaderColumn.CellStyle = headerRow.GetCell(h).CellStyle;
                additionalHeaderColumn.SetCellValue(headerRow.GetCell(h).RichStringCellValue);
            }
    
            rowIndex = 1;
        }
    
        // Create new detail row in sheet
        HSSFRow dataRow = sheet.CreateRow(rowIndex);
        // Loop the columns from the DataRow and add using dataRow.CreateCell(#)....
    }
  • 相关阅读:
    远程访问Linux系统桌面
    NFS原理详解
    编译portmap和nfs-utils
    NFS资料
    PF_NETLINK应用实例NETLINK_KOBJECT_UEVENT具体实现--udev实现原理
    usb资料2
    USB相关资料
    书籍
    最详细的Log4j使用教程
    iOS开发UI篇—无限轮播(新闻数据展示)
  • 原文地址:https://www.cnblogs.com/automation/p/2864861.html
Copyright © 2011-2022 走看看