while(prev.getFirstCellNum() != -1) { prev.removeCell(prev.getCell(prev.getFirstCellNum()));
/** * Ungroup a range of rows that were previously groupped * * @param fromRow start row (0-based) * @param toRow end row (0-based) */ @Override public void ungroupRow(int fromRow, int toRow) { for (int i = fromRow; i <= toRow; i++) { XSSFRow xrow = getRow(i); if (xrow != null) { CTRow ctRow = xrow.getCTRow(); int outlineLevel = ctRow.getOutlineLevel(); ctRow.setOutlineLevel((short) (outlineLevel - 1)); //remove a row only if the row has no cell and if the outline level is 0 if (outlineLevel == 1 && xrow.getFirstCellNum() == -1) { removeRow(xrow); } } } setSheetFormatPrOutlineLevelRow(); }
if(row.getFirstCellNum() != -1) { minCell = Math.min(minCell, row.getFirstCellNum());
public XSSFRow createRow(int rownum) { CTRow ctRow; XSSFRow prev = _rows.get(rownum); if(prev != null){ // the Cells in an existing row are invalidated on-purpose, in order to clean up correctly, we // need to call the remove, so things like ArrayFormulas and CalculationChain updates are done // correctly. // We remove the cell this way as the internal cell-list is changed by the remove call and // thus would cause ConcurrentModificationException otherwise while(prev.getFirstCellNum() != -1) { prev.removeCell(prev.getCell(prev.getFirstCellNum())); } ctRow = prev.getCTRow(); ctRow.set(CTRow.Factory.newInstance()); } ... }
for (int j = row.getFirstCellNum(); j < row.getLastCellNum(); j++)
while(prev.getFirstCellNum() != -1) { prev.removeCell(prev.getCell(prev.getFirstCellNum()));
// Open workbook and sheet final XSSFWorkbook workbook = new XSSFWorkbook(new File("filename.xlsx")); final XSSFSheet sheet = workbook.getSheetAt(0); // Iterate rows final int firstRowNumber = sheet.getFirstRowNum(); final int lastRowNumber = sheet.getLastRowNum(); for (int rowNumber = firstRowNumber; rowNumber < lastRowNumber; rowNumber++ ) { final XSSFRow row = sheet.getRow(rowNumber); if (row == null) continue; // Iterate columns final int firstColumnNumber = row.getFirstCellNum(); final int lastColumnNumber = row.getLastCellNum(); for (int columnNumber = firstColumnNumber; columnNumber < lastColumnNumber; columnNumber++ ) { final XSSFCell cell = row.getCell(firstColumnNumber); if (cell == null) continue; // Make some changes cell.setCellValue("new Value"); } } // Save changes workbook.write(new FileOutputStream("newFilename.xlsx"));
int index = title.getFirstCellNum(); int rowcount = title.getLastCellNum(); for (int i = 1; i < rows; i++){
/** * Ungroup a range of rows that were previously groupped * * @param fromRow start row (0-based) * @param toRow end row (0-based) */ @Override public void ungroupRow(int fromRow, int toRow) { for (int i = fromRow; i <= toRow; i++) { XSSFRow xrow = getRow(i); if (xrow != null) { CTRow ctRow = xrow.getCTRow(); int outlineLevel = ctRow.getOutlineLevel(); ctRow.setOutlineLevel((short) (outlineLevel - 1)); //remove a row only if the row has no cell and if the outline level is 0 if (outlineLevel == 1 && xrow.getFirstCellNum() == -1) { removeRow(xrow); } } } setSheetFormatPrOutlineLevelRow(); }
for (int i = sourceRow.getFirstCellNum(); i <= sourceRow.getLastCellNum(); i++) { XSSFCell sourceCell = sourceRow.getCell(i); SXSSFCell targetCell = (SXSSFCell) targetRow.getCell(i);
/** * Ungroup a range of rows that were previously groupped * * @param fromRow start row (0-based) * @param toRow end row (0-based) */ public void ungroupRow(int fromRow, int toRow) { for (int i = fromRow; i <= toRow; i++) { XSSFRow xrow = getRow(i); if (xrow != null) { CTRow ctrow = xrow.getCTRow(); short outlinelevel = ctrow.getOutlineLevel(); ctrow.setOutlineLevel((short) (outlinelevel - 1)); //remove a row only if the row has no cell and if the outline level is 0 if (ctrow.getOutlineLevel() == 0 && xrow.getFirstCellNum() == -1) { removeRow(xrow); } } } setSheetFormatPrOutlineLevelRow(); }
if(row.getFirstCellNum() != -1) { minCell = Math.min(minCell, row.getFirstCellNum());
newRow.setHeight(oldRow.getHeight()); for (int columnNumber = oldRow.getFirstCellNum(); columnNumber < oldRow .getLastCellNum(); columnNumber++) { newSheet.setColumnWidth(columnNumber, oldSheet.getColumnWidth(columnNumber));