List of usage examples for org.apache.poi.ss.util CellAddress getColumn
public int getColumn()
From source file:com.dua3.meja.model.poi.PoiSheet.java
License:Apache License
@Override public PoiCell getCurrentCell() { final int currentRow, currentColumn; CellAddress cellRef = poiSheet.getActiveCell(); if (cellRef != null) { currentRow = Math.max(getFirstRowNum(), Math.min(getLastRowNum(), cellRef.getRow())); currentColumn = Math.max(getFirstColNum(), Math.min(getLastColNum(), cellRef.getColumn())); } else {/*from ww w . j a v a 2 s. c o m*/ currentRow = poiSheet.getTopRow(); currentColumn = poiSheet.getLeftCol(); } return getCell(currentRow, currentColumn); }
From source file:offishell.excel.Excel.java
License:MIT License
public Excel calculate(Object model) { Map<CellAddress, XSSFComment> cellComments = sheet.getCellComments(); VariableContext context = new VariableContext(path, false, model); for (Iterator<Entry<CellAddress, XSSFComment>> iterator = cellComments.entrySet().iterator(); iterator .hasNext();) {// w w w. j a v a2s . c o m Entry<CellAddress, XSSFComment> entry = iterator.next(); CellAddress address = entry.getKey(); String comment = entry.getValue().getString().getString().strip(); entry.getValue().setVisible(false); XSSFCell cell = sheet.getRow(address.getRow()).getCell(address.getColumn()); cell.setCellValue(context.apply(comment)); cell.removeCellComment(); } try { return save(Files.createTempFile("calculated", ".xlsx")); } catch (IOException e) { throw I.quiet(e); } }
From source file:org.tiefaces.components.websheet.configuration.ConfigurationHandler.java
License:MIT License
/** * build command list from comments. after transfer the comment to command, * remove it from comments.//from www . ja v a 2 s .c o m * * @param sheet * sheet. * @param sheetRightCol * the sheet right col * @param cellAttributesMap * the cell attributes map * @return command list. */ private List<ConfigCommand> buildCommandListFromSheetComment(final XSSFSheet sheet, final int sheetRightCol, final CellAttributesMap cellAttributesMap) { List<ConfigCommand> commandList = new ArrayList<>(); // if skip then return empty list. if (parent.isSkipConfiguration()) { return commandList; } Map<CellAddress, ? extends Comment> comments = null; try { // due to a poi bug. null exception throwed if no comments in the // sheet. comments = sheet.getCellComments(); } catch (Exception ex) { LOG.log(Level.FINE, "Null exception throwed when no comment exists: " + ex.getLocalizedMessage(), ex); } if (comments == null) { return commandList; } // not sure the map is sorted. So use tree map to sort it. SortedSet<CellAddress> keys = new TreeSet<>(comments.keySet()); // go through each comments // if found tie command then transfer it to list also remove from // comments. for (CellAddress key : keys) { Cell cell = sheet.getRow(key.getRow()).getCell(key.getColumn(), MissingCellPolicy.CREATE_NULL_AS_BLANK); buildCommandList(sheet, sheetRightCol, cell, commandList, cellAttributesMap); } return commandList; }
From source file:uk.ac.manchester.cs.owl.semspreadsheets.ui.SheetTable.java
License:BSD License
protected void paintComponent(Graphics g) { try {// www . ja v a 2 s. com super.paintComponent(g); } catch (XmlValueDisconnectedException e) { logger.warn("XmlValueDisconnectedException whilst repainting table"); } Color oldColor = g.getColor(); Graphics2D g2 = (Graphics2D) g; Stroke oldStroke = g2.getStroke(); g2.setStroke(stroke); for (OntologyTermValidation ontologyTermValidation : workbookManager.getOntologyManager() .getOntologyTermValidations()) { if (ontologyTermValidation.getRange().getSheet().equals(sheet)) { Range validation = ontologyTermValidation.getRange(); OntologyTermValidationDescriptor validationDescriptor = ontologyTermValidation .getValidationDescriptor(); if (!validationDescriptor.definesLiteral() && validationDescriptor.getTerms().isEmpty()) { g.setColor(emptyValidationColour); } else { g.setColor(validationAppliedColour); } Rectangle startRect = getCellRect(validation.getFromRow(), validation.getFromColumn(), false); Rectangle endRect = getCellRect(validation.getToRow(), validation.getToColumn(), false); int x1 = startRect.x + 1; int y1 = startRect.y + 1; int width = endRect.width + endRect.x - startRect.x - 2; int height = endRect.y + endRect.height - startRect.y - 2; Rectangle rect = new Rectangle(x1, y1, width, height); Composite oldComposite = g2.getComposite(); g2.setComposite(alphaComposite2); g2.drawRoundRect(rect.x, rect.y, rect.width, rect.height, 5, 5); g2.setComposite(alphaComposite); g2.fill(rect); g2.setComposite(oldComposite); } } Sheet sheet = workbookManager.getSelectionModel().getSelectedRange().getSheet(); if (sheet != null) { for (String entry : workbookManager.getLinkedCells(sheet.getName())) { Range validation; String cellString = entry.split(",")[0]; Color color; String test = entry.split(",")[1]; if (test.equals("BLUE")) { color = Color.BLUE; } else if (test.equals("RED")) { color = Color.RED; } else if (test.equals("MAGENTA")) { color = Color.MAGENTA; } else if (test.equals("ORANGE")) { color = Color.ORANGE; } else if (test.equals("CYAN")) { color = Color.CYAN; } else if (test.equals("GRAY")) { color = Color.GRAY; } else { color = Color.PINK; } int noOfColumns = Integer.parseInt(entry.split(",")[2]); CellAddress da = new CellAddress(cellString); for (int i = 0; i < noOfColumns; i++) { if (sheet.getCellAt(da.getColumn() + i, da.getRow()) == null) { sheet.addCellAt(da.getColumn() + i, da.getRow()); } } validation = new Range(sheet, da.getColumn(), da.getRow(), da.getColumn() + noOfColumns - 1, da.getRow()); g.setColor(color); Rectangle startRect = getCellRect(validation.getFromRow(), validation.getFromColumn(), false); Rectangle endRect = getCellRect(validation.getToRow(), validation.getToColumn(), false); int x1 = startRect.x + 1; int y1 = startRect.y + 1; int width = endRect.width + endRect.x - startRect.x - 2; int height = endRect.y + endRect.height - startRect.y - 2; Rectangle rect = new Rectangle(x1, y1, width, height); Composite oldComposite = g2.getComposite(); g2.setComposite(alphaComposite2); g2.drawRoundRect(rect.x, rect.y, rect.width, rect.height, 5, 5); g2.setComposite(alphaComposite); g2.setComposite(oldComposite); } } g2.setStroke(oldStroke); g.setColor(oldColor); }