Java Code Examples for org.apache.poi.ss.SpreadsheetVersion#EXCEL97
The following examples show how to use
org.apache.poi.ss.SpreadsheetVersion#EXCEL97 .
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: SharedFormulaRecord.java From lams with GNU General Public License v2.0 | 5 votes |
/** * @return the equivalent {@link Ptg} array that the formula would have, were it not shared. */ public Ptg[] getFormulaTokens(FormulaRecord formula) { int formulaRow = formula.getRow(); int formulaColumn = formula.getColumn(); //Sanity checks if (!isInRange(formulaRow, formulaColumn)) { throw new RuntimeException("Shared Formula Conversion: Coding Error"); } SharedFormula sf = new SharedFormula(SpreadsheetVersion.EXCEL97); return sf.convertSharedFormulas(field_7_parsed_expr.getTokens(), formulaRow, formulaColumn); }
Example 2
Source File: POIUtils.java From xlsmapper with Apache License 2.0 | 5 votes |
/** * シートの種類を判定する。 * * @since 2.0 * @param sheet 判定対象のオブジェクト * @return シートの種類。不明な場合はnullを返す。 * @throws IllegalArgumentException {@literal sheet == null} */ public static SpreadsheetVersion getVersion(final Sheet sheet) { ArgUtils.notNull(sheet, "sheet"); if(sheet instanceof HSSFSheet) { return SpreadsheetVersion.EXCEL97; } else if(sheet instanceof XSSFSheet) { return SpreadsheetVersion.EXCEL2007; } return null; }
Example 3
Source File: HSSFRangeHelper.java From yarg with Apache License 2.0 | 5 votes |
public static AreaReference getAreaForRange(HSSFWorkbook workbook, String rangeName) { int rangeNameIdx = workbook.getNameIndex(rangeName); if (rangeNameIdx == -1) return null; HSSFName aNamedRange = workbook.getNameAt(rangeNameIdx); return new AreaReference(aNamedRange.getRefersToFormula(), SpreadsheetVersion.EXCEL97); }
Example 4
Source File: AreaPtg.java From lams with GNU General Public License v2.0 | 4 votes |
/** * @deprecated use {@link #AreaPtg(AreaReference)} instead */ @Deprecated() @Removal(version="3.19") public AreaPtg(String arearef) { this(new AreaReference(arearef, SpreadsheetVersion.EXCEL97)); }
Example 5
Source File: Area3DPtg.java From lams with GNU General Public License v2.0 | 4 votes |
public Area3DPtg(String arearef, int externIdx) { super(new AreaReference(arearef, SpreadsheetVersion.EXCEL97)); setExternSheetIndex(externIdx); }
Example 6
Source File: HSSFEvaluationWorkbook.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public SpreadsheetVersion getSpreadsheetVersion(){ return SpreadsheetVersion.EXCEL97; }
Example 7
Source File: Area.java From yarg with Apache License 2.0 | 4 votes |
public AreaReference toAreaReference() { return new AreaReference(topLeft.toCellReference(), bottomRight.toCellReference(), SpreadsheetVersion.EXCEL97); }
Example 8
Source File: XLSFormatter.java From yarg with Apache License 2.0 | 4 votes |
/** * Method creates mapping [rangeName : List<CellRangeAddress>]. * List contains all merge regions for this named range. * Attention: if merged regions writes wrong - look on methods isMergeRegionInsideNamedRange or isNamedRangeInsideMergeRegion * todo: how to recognize if merge region must be copied with named range * * @param currentSheet Sheet which contains merge regions */ protected void initMergeRegions(HSSFSheet currentSheet) { int rangeNumber = templateWorkbook.getNumberOfNames(); for (int i = 0; i < rangeNumber; i++) { HSSFName aNamedRange = templateWorkbook.getNameAt(i); String refersToFormula = aNamedRange.getRefersToFormula(); if (!AreaReference.isContiguous(refersToFormula)) { continue; } AreaReference aref = new AreaReference(refersToFormula, SpreadsheetVersion.EXCEL97); Integer rangeFirstRow = aref.getFirstCell().getRow(); Integer rangeFirstColumn = (int) aref.getFirstCell().getCol(); Integer rangeLastRow = aref.getLastCell().getRow(); Integer rangeLastColumn = (int) aref.getLastCell().getCol(); for (int j = 0; j < currentSheet.getNumMergedRegions(); j++) { CellRangeAddress mergedRegion = currentSheet.getMergedRegion(j); if (mergedRegion != null) { Integer regionFirstRow = mergedRegion.getFirstRow(); Integer regionFirstColumn = mergedRegion.getFirstColumn(); Integer regionLastRow = mergedRegion.getLastRow(); Integer regionLastColumn = mergedRegion.getLastColumn(); boolean mergedInsideNamed = isMergeRegionInsideNamedRange( rangeFirstRow, rangeFirstColumn, rangeLastRow, rangeLastColumn, regionFirstRow, regionFirstColumn, regionLastRow, regionLastColumn); boolean namedInsideMerged = isNamedRangeInsideMergeRegion( rangeFirstRow, rangeFirstColumn, rangeLastRow, rangeLastColumn, regionFirstRow, regionFirstColumn, regionLastRow, regionLastColumn); if (mergedInsideNamed || namedInsideMerged) { String name = aNamedRange.getNameName(); SheetRange sheetRange = new SheetRange(mergedRegion, currentSheet.getSheetName()); if (mergeRegionsForRangeNames.get(name) == null) { ArrayList<SheetRange> list = new ArrayList<>(); list.add(sheetRange); mergeRegionsForRangeNames.put(name, list); } else { mergeRegionsForRangeNames.get(name).add(sheetRange); } } } } } }
Example 9
Source File: XLSFormatter.java From yarg with Apache License 2.0 | 4 votes |
/** * Create new merge regions in result sheet identically to range's merge regions from template. * Not support copy of frames and rules * * @param resultSheet - result sheet * @param rangeName - range name * @param firstTargetRangeRow - first column of target range * @param firstTargetRangeColumn - first column of target range */ protected void copyMergeRegions(HSSFSheet resultSheet, String rangeName, int firstTargetRangeRow, int firstTargetRangeColumn) { int rangeNameIdx = templateWorkbook.getNameIndex(rangeName); if (rangeNameIdx == -1) return; HSSFName aNamedRange = templateWorkbook.getNameAt(rangeNameIdx); AreaReference aref = new AreaReference(aNamedRange.getRefersToFormula(), SpreadsheetVersion.EXCEL97); int column = aref.getFirstCell().getCol(); int row = aref.getFirstCell().getRow(); List<SheetRange> regionsList = mergeRegionsForRangeNames.get(rangeName); if (regionsList != null) for (SheetRange sheetRange : regionsList) { if (resultSheet.getSheetName().equals(sheetRange.getSheetName())) { CellRangeAddress cra = sheetRange.getCellRangeAddress(); if (cra != null) { int regionHeight = cra.getLastRow() - cra.getFirstRow() + 1; int regionWidth = cra.getLastColumn() - cra.getFirstColumn() + 1; int regionVOffset = cra.getFirstRow() - row; int regionHOffset = cra.getFirstColumn() - column; CellRangeAddress newRegion = cra.copy(); newRegion.setFirstColumn(regionHOffset + firstTargetRangeColumn); newRegion.setLastColumn(regionHOffset + regionWidth - 1 + firstTargetRangeColumn); newRegion.setFirstRow(regionVOffset + firstTargetRangeRow); newRegion.setLastRow(regionVOffset + regionHeight - 1 + firstTargetRangeRow); boolean skipRegion = false; for (int mergedIndex = 0; mergedIndex < resultSheet.getNumMergedRegions(); mergedIndex++) { CellRangeAddress mergedRegion = resultSheet.getMergedRegion(mergedIndex); if (!intersects(newRegion, mergedRegion)) { continue; } skipRegion = true; } if (!skipRegion) { resultSheet.addMergedRegion(newRegion); } } } } }
Example 10
Source File: FormulaParser.java From lams with GNU General Public License v2.0 | 3 votes |
/** * Create the formula parser, with the string that is to be * parsed against the supplied workbook. * A later call the parse() method to return ptg list in * rpn order, then call the getRPNPtg() to retrieve the * parse results. * This class is recommended only for single threaded use. * * If you have a {@link org.apache.poi.hssf.usermodel.HSSFWorkbook}, and not a * {@link org.apache.poi.ss.usermodel.Workbook}, then use the convenience method on * {@link org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator} */ private FormulaParser(String formula, FormulaParsingWorkbook book, int sheetIndex, int rowIndex) { _formulaString = formula; _pointer=0; _book = book; _ssVersion = book == null ? SpreadsheetVersion.EXCEL97 : book.getSpreadsheetVersion(); _formulaLength = _formulaString.length(); _sheetIndex = sheetIndex; _rowIndex = rowIndex; }
Example 11
Source File: HSSFWorkbook.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Returns the spreadsheet version (EXCLE97) of this workbook * * @return EXCEL97 SpreadsheetVersion enum * @since 3.14 beta 2 */ @Override public SpreadsheetVersion getSpreadsheetVersion() { return SpreadsheetVersion.EXCEL97; }
Example 12
Source File: AreaReference.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Create an area ref from a string representation. Sheet names containing special characters should be * delimited and escaped as per normal syntax rules for formulas.<br> * The area reference must be contiguous (i.e. represent a single rectangle, not a union of rectangles) */ public AreaReference(String reference) { super(reference, SpreadsheetVersion.EXCEL97); }