protected AbstractCellRangeDataSource(XSSFSheet sheet, CellRangeAddress cellRangeAddress) { this.sheet = sheet; // Make copy since CellRangeAddress is mutable. this.cellRangeAddress = cellRangeAddress.copy(); this.numOfCells = this.cellRangeAddress.getNumberOfCells(); this.evaluator = sheet.getWorkbook().getCreationHelper().createFormulaEvaluator(); }
/** * Constructs ExcellDataObjectAdaptor object Collection = an Excel work book * sheet * * @param dataFilePath path to an Excel file * @param sheetName sheet name * @throws DataException if file not found */ public ExcelDataObjectAdaptor(String dataFilePath, String sheetName) throws DataException { File file = FileUtils.getFile(dataFilePath + ".xlsx"); if (null == file) { throw new FileNotFoundException(format("Could not find data file: '%s'", dataFilePath)); } this.dataFileName = file.getName().replace(".xlsx", ""); try { this.workBook = new XSSFWorkbook(file); } catch (IOException | InvalidFormatException ex) { throw new DataParseException("Could not parse \"" + file + "\"", ex); } this.sheetName = sheetName; this.basicObj = parseCollection(); this.evaluator = workBook.getCreationHelper().createFormulaEvaluator(); }
/** * Constructs ExcelDataProvider object Collection = an Excel work book * sheet * * @param dataFilePath path to an Excel file * @param collectionName sheet name * @throws DataException if file not found */ public ExcelDataProvider(String dataFilePath, String collectionName) throws DataException { File file = FileUtils.getFile(dataFilePath + "." + DEFAULT_EXTENSION); if (null == file) { throw new FileNotFoundException(format("Could not find data file: '%s'", dataFilePath)); } this.dataFileName = file.getName().replace(DEFAULT_EXTENSION, ""); try { this.workBook = new XSSFWorkbook(file); } catch (IOException | InvalidFormatException ex) { throw new DataParseException("Could not parse \"" + file + "\"", ex); } this.collectionName = collectionName; this.basicObject = parseCollection(); this.evaluator = workBook.getCreationHelper().createFormulaEvaluator(); }
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); for (int i = 0; i < numberOfSheets; i++) { template.add(new ArrayList<String>());
protected AbstractCellRangeDataSource(XSSFSheet sheet, CellRangeAddress cellRangeAddress) { this.sheet = sheet; // Make copy since CellRangeAddress is mutable. this.cellRangeAddress = cellRangeAddress.copy(); this.numOfCells = this.cellRangeAddress.getNumberOfCells(); this.evaluator = sheet.getWorkbook().getCreationHelper().createFormulaEvaluator(); }
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); while (rowIterator.hasNext() && counter <= data.length) { Row row = rowIterator.next();
public void onReadClick(View view) { printlnToUser("reading XLSX file from resources"); InputStream stream = getResources().openRawResource(R.raw.test1); try { XSSFWorkbook workbook = new XSSFWorkbook(stream); XSSFSheet sheet = workbook.getSheetAt(0); int rowsCount = sheet.getPhysicalNumberOfRows(); FormulaEvaluator formulaEvaluator = workbook.getCreationHelper().createFormulaEvaluator(); for (int r = 0; r<rowsCount; r++) { Row row = sheet.getRow(r); int cellsCount = row.getPhysicalNumberOfCells(); for (int c = 0; c<cellsCount; c++) { String value = getCellAsString(row, c, formulaEvaluator); String cellInfo = "r:"+r+"; c:"+c+"; v:"+value; printlnToUser(cellInfo); } } } catch (Exception e) { /* proper exception handling to be here */ printlnToUser(e.toString()); } }
Excel self = new Excel(); String value = "";// + cell.getStringCellValue();//.getNumericCellValue(); FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); try { if (cell != null) {