Java Code Examples for org.apache.poi.ss.util.CellAddress#getColumn()
The following examples show how to use
org.apache.poi.ss.util.CellAddress#getColumn() .
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: PoijiHandler.java From poiji with MIT License | 6 votes |
@Override public void cell(String cellReference, String formattedValue, XSSFComment comment) { CellAddress cellAddress = new CellAddress(cellReference); int row = cellAddress.getRow(); int headers = options.getHeaderStart(); int column = cellAddress.getColumn(); if (row <= headers) { columnIndexPerTitle.put( options.getCaseInsensitive() ? formattedValue.toLowerCase() : formattedValue, column ); titlePerColumnIndex.put(column, getTitleNameForMap(formattedValue, column)); } if (row + 1 <= options.skip()) { return; } if (limit != 0 && internalCount > limit) { return; } internalRow = row; setFieldValue(formattedValue, type, column); }
Example 2
Source File: XSSFEventParser.java From hadoopoffice with Apache License 2.0 | 6 votes |
@Override public void cell(String cellReference, String formattedValue, XSSFComment comment) { // create empty column, if needed CellAddress currentCellAddress = new CellAddress(cellReference); for (int i=this.currentColumn;i<currentCellAddress.getColumn();i++) { this.spreadSheetCellDAOCurrentRow.add(null); this.currentColumn++; } // add column SpreadSheetCellDAO currentDAO = null; if (comment!=null) { currentDAO = new SpreadSheetCellDAO(formattedValue,comment.getString().getString(), "", cellReference,this.sheetName); } else { currentDAO = new SpreadSheetCellDAO(formattedValue,"", "", cellReference,this.sheetName); } this.currentColumn++; this.spreadSheetCellDAOCurrentRow.add(currentDAO); }
Example 3
Source File: HSSFSheet.java From lams with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void setActiveCell(CellAddress address) { int row = address.getRow(); short col = (short) address.getColumn(); _sheet.setActiveCellRow(row); _sheet.setActiveCellCol(col); }
Example 4
Source File: ExcelServices.java From M2Doc with Eclipse Public License 1.0 | 4 votes |
@Documentation( value = "Insert a table from an Excel .xlsx file.", params = { @Param(name = "uri", value = "The Excel .xlsx file uri, it can be relative to the template"), @Param(name = "sheetName", value = "The sheet name"), @Param(name = "topLeftCellAdress", value = "The top left cell address"), @Param(name = "bottomRightCellAdress", value = "The bottom right cell address"), @Param(name = "languageTag", value = "The language tag for the locale"), }, result = "insert the table", examples = { @Example(expression = "'excel.xlsx'.asTable('Feuil1', 'C3', 'F7', 'fr-FR')", result = "insert the table from 'excel.xlsx'"), } ) // @formatter:on public MTable asTable(String uriStr, String sheetName, String topLeftCellAdress, String bottomRightCellAdress, String languageTag) throws IOException { final MTable res = new MTableImpl(); final URI xlsxURI = URI.createURI(uriStr, false); final URI uri = xlsxURI.resolve(templateURI); try (XSSFWorkbook workbook = new XSSFWorkbook(uriConverter.createInputStream(uri));) { final FormulaEvaluator evaluator = new XSSFFormulaEvaluator(workbook); final XSSFSheet sheet = workbook.getSheet(sheetName); if (sheet == null) { throw new IllegalArgumentException(String.format("The sheet %s doesn't exist in %s.", sheetName, uri)); } else { final Locale locale; if (languageTag != null) { locale = Locale.forLanguageTag(languageTag); } else { locale = Locale.getDefault(); } final DataFormatter dataFormatter = new DataFormatter(locale); final CellAddress start = new CellAddress(topLeftCellAdress); final CellAddress end = new CellAddress(bottomRightCellAdress); int rowIndex = start.getRow(); while (rowIndex <= end.getRow()) { final XSSFRow row = sheet.getRow(rowIndex++); if (row != null) { final MRow mRow = new MRowImpl(); int cellIndex = start.getColumn(); while (cellIndex <= end.getColumn()) { final XSSFCell cell = row.getCell(cellIndex++); if (cell != null) { final MStyle style = getStyle(cell); final MElement text = new MTextImpl(dataFormatter.formatCellValue(cell, evaluator), style); final Color background = getColor(cell.getCellStyle().getFillForegroundColorColor()); final MCell mCell = new MCellImpl(text, background); mRow.getCells().add(mCell); } else { mRow.getCells().add(createEmptyCell()); } } res.getRows().add(mRow); } else { final int length = end.getColumn() - start.getColumn() + 1; res.getRows().add(createEmptyRow(length)); } } } } return res; }