List of usage examples for org.apache.poi.xssf.streaming SXSSFSheet getFirstRowNum
@Override public int getFirstRowNum()
From source file:com.plugin.excel.util.ExcelUtil.java
License:Apache License
/** * @param newSheet// www . j a v a2 s . co m * the sheet to create from the copy. * @param sheet * the sheet to copy. * @param copyStyle * true copy the style. */ public static void copySheets(SXSSFSheet newSheet, SXSSFSheet sheet, boolean copyStyle) { int maxColumnNum = 0; Map<Integer, CellStyle> styleMap = (copyStyle) ? new HashMap<Integer, CellStyle>() : null; for (int i = sheet.getFirstRowNum(); i <= sheet.getLastRowNum(); i++) { Row srcRow = sheet.getRow(i); Row destRow = newSheet.createRow(i); if (srcRow != null) { ExcelUtil.copyRow(sheet, newSheet, srcRow, destRow, styleMap); if (srcRow.getLastCellNum() > maxColumnNum) { maxColumnNum = srcRow.getLastCellNum(); } } } for (int i = 0; i <= maxColumnNum; i++) { newSheet.setColumnWidth(i, sheet.getColumnWidth(i)); } }