/** * <p>This method attempts to find an existing CellStyle that matches the <code>cell</code>'s * current style plus a single style property <code>propertyName</code> with value * <code>propertyValue</code>. * A new style is created if the workbook does not contain a matching style.</p> * * <p>Modifies the cell style of <code>cell</code> without affecting other cells that use the * same style.</p> * * <p>If setting more than one cell style property on a cell, use * {@link #setCellStyleProperties(org.apache.poi.ss.usermodel.Cell, Map)}, * which is faster and does not add unnecessary intermediate CellStyles to the workbook.</p> * * @param cell The cell that is to be changed. * @param propertyName The name of the property that is to be changed. * @param propertyValue The value of the property that is to be changed. */ public static void setCellStyleProperty(Cell cell, String propertyName, Object propertyValue) { Map<String, Object> property = Collections.singletonMap(propertyName, propertyValue); setCellStyleProperties(cell, property); }
/** * Applies the drawn borders to a Sheet. The borders that are applied are * the ones that have been drawn by the {@link #drawBorders} and * {@link #drawBorderColors} methods. * * @param sheet * - {@link Sheet} on which to apply borders */ public void applyBorders(Sheet sheet) { Workbook wb = sheet.getWorkbook(); for (Map.Entry<CellAddress, Map<String, Object>> entry : _propertyTemplate .entrySet()) { CellAddress cellAddress = entry.getKey(); if (cellAddress.getRow() < wb.getSpreadsheetVersion().getMaxRows() && cellAddress.getColumn() < wb.getSpreadsheetVersion() .getMaxColumns()) { Map<String, Object> properties = entry.getValue(); Row row = CellUtil.getRow(cellAddress.getRow(), sheet); Cell cell = CellUtil.getCell(row, cellAddress.getColumn()); CellUtil.setCellStyleProperties(cell, properties); } } }
/** * <p>This method attempts to find an existing CellStyle that matches the <code>cell</code>'s * current style plus a single style property <code>propertyName</code> with value * <code>propertyValue</code>. * A new style is created if the workbook does not contain a matching style.</p> * * <p>Modifies the cell style of <code>cell</code> without affecting other cells that use the * same style.</p> * * <p>If setting more than one cell style property on a cell, use * {@link #setCellStyleProperties(org.apache.poi.ss.usermodel.Cell, Map)}, * which is faster and does not add unnecessary intermediate CellStyles to the workbook.</p> * * @param cell The cell that is to be changed. * @param propertyName The name of the property that is to be changed. * @param propertyValue The value of the property that is to be changed. */ public static void setCellStyleProperty(Cell cell, String propertyName, Object propertyValue) { Map<String, Object> property = Collections.singletonMap(propertyName, propertyValue); setCellStyleProperties(cell, property); }
/** * Applies the drawn borders to a Sheet. The borders that are applied are * the ones that have been drawn by the {@link #drawBorders} and * {@link #drawBorderColors} methods. * * @param sheet * - {@link Sheet} on which to apply borders */ public void applyBorders(Sheet sheet) { Workbook wb = sheet.getWorkbook(); for (Map.Entry<CellAddress, Map<String, Object>> entry : _propertyTemplate .entrySet()) { CellAddress cellAddress = entry.getKey(); if (cellAddress.getRow() < wb.getSpreadsheetVersion().getMaxRows() && cellAddress.getColumn() < wb.getSpreadsheetVersion() .getMaxColumns()) { Map<String, Object> properties = entry.getValue(); Row row = CellUtil.getRow(cellAddress.getRow(), sheet); Cell cell = CellUtil.getCell(row, cellAddress.getColumn()); CellUtil.setCellStyleProperties(cell, properties); } } }