org.apache.poi.ss.usermodel.CellRange Java Examples
The following examples show how to use
org.apache.poi.ss.usermodel.CellRange.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HSSFSheet.java From lams with GNU General Public License v2.0 | 7 votes |
/** * Also creates cells if they don't exist */ private CellRange<HSSFCell> getCellRange(CellRangeAddress range) { int firstRow = range.getFirstRow(); int firstColumn = range.getFirstColumn(); int lastRow = range.getLastRow(); int lastColumn = range.getLastColumn(); int height = lastRow - firstRow + 1; int width = lastColumn - firstColumn + 1; List<HSSFCell> temp = new ArrayList<HSSFCell>(height * width); for (int rowIn = firstRow; rowIn <= lastRow; rowIn++) { for (int colIn = firstColumn; colIn <= lastColumn; colIn++) { HSSFRow row = getRow(rowIn); if (row == null) { row = createRow(rowIn); } HSSFCell cell = row.getCell(colIn); if (cell == null) { cell = row.createCell(colIn); } temp.add(cell); } } return SSCellRange.create(firstRow, firstColumn, height, width, temp, HSSFCell.class); }
Example #2
Source File: HSSFSheet.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public CellRange<HSSFCell> removeArrayFormula(Cell cell) { if (cell.getSheet() != this) { throw new IllegalArgumentException("Specified cell does not belong to this sheet."); } CellValueRecordInterface rec = ((HSSFCell) cell).getCellValueRecord(); if (!(rec instanceof FormulaRecordAggregate)) { String ref = new CellReference(cell).formatAsString(); throw new IllegalArgumentException("Cell " + ref + " is not part of an array formula."); } FormulaRecordAggregate fra = (FormulaRecordAggregate) rec; CellRangeAddress range = fra.removeArrayFormula(cell.getRowIndex(), cell.getColumnIndex()); CellRange<HSSFCell> result = getCellRange(range); // clear all cells in the range for (Cell c : result) { c.setCellType(CellType.BLANK); } return result; }
Example #3
Source File: HSSFSheet.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public CellRange<HSSFCell> setArrayFormula(String formula, CellRangeAddress range) { // make sure the formula parses OK first int sheetIndex = _workbook.getSheetIndex(this); Ptg[] ptgs = HSSFFormulaParser.parse(formula, _workbook, FormulaType.ARRAY, sheetIndex); CellRange<HSSFCell> cells = getCellRange(range); for (HSSFCell c : cells) { c.setCellArrayFormula(range); } HSSFCell mainArrayFormulaCell = cells.getTopLeftCell(); FormulaRecordAggregate agg = (FormulaRecordAggregate) mainArrayFormulaCell.getCellValueRecord(); agg.setArrayFormula(range, ptgs); return cells; }
Example #4
Source File: StreamingSheet.java From data-prep with Apache License 2.0 | 4 votes |
/** * Not supported */ @Override public CellRange<? extends Cell> setArrayFormula(String formula, CellRangeAddress range) { throw new UnsupportedOperationException(); }
Example #5
Source File: StreamingSheet.java From data-prep with Apache License 2.0 | 4 votes |
/** * Not supported */ @Override public CellRange<? extends Cell> removeArrayFormula(Cell cell) { throw new UnsupportedOperationException(); }
Example #6
Source File: FilteredSheet.java From birt with Eclipse Public License 1.0 | 4 votes |
public CellRange<? extends Cell> setArrayFormula(String formula, CellRangeAddress range) { return sheet.setArrayFormula(formula, range); }
Example #7
Source File: FilteredSheet.java From birt with Eclipse Public License 1.0 | 4 votes |
public CellRange<? extends Cell> removeArrayFormula(Cell cell) { return sheet.removeArrayFormula(cell); }
Example #8
Source File: StreamingSheet.java From excel-streaming-reader with Apache License 2.0 | 4 votes |
/** * Not supported */ @Override public CellRange<? extends Cell> setArrayFormula(String formula, CellRangeAddress range) { throw new UnsupportedOperationException(); }
Example #9
Source File: StreamingSheet.java From excel-streaming-reader with Apache License 2.0 | 4 votes |
/** * Not supported */ @Override public CellRange<? extends Cell> removeArrayFormula(Cell cell) { throw new UnsupportedOperationException(); }