/** * Take a cell, and align it. * * This is superior to cell.getCellStyle().setAlignment(align) because * this method will not modify the CellStyle object that may be referenced * by multiple cells. Instead, this method will search for existing CellStyles * that match the desired CellStyle, creating a new CellStyle with the desired * style if no match exists. * * @param cell the cell to set the alignment for * @param align the horizontal alignment to use. * * @see HorizontalAlignment for alignment options * @since POI 3.15 beta 3 */ public static void setAlignment(Cell cell, HorizontalAlignment align) { setCellStyleProperty(cell, ALIGNMENT, align); }
/** * Take a cell, and vertically align it. * * This is superior to cell.getCellStyle().setVerticalAlignment(align) because * this method will not modify the CellStyle object that may be referenced * by multiple cells. Instead, this method will search for existing CellStyles * that match the desired CellStyle, creating a new CellStyle with the desired * style if no match exists. * * @param cell the cell to set the alignment for * @param align the vertical alignment to use. * * @see VerticalAlignment for alignment options * @since POI 3.15 beta 3 */ public static void setVerticalAlignment(Cell cell, VerticalAlignment align) { setCellStyleProperty(cell, VERTICAL_ALIGNMENT, align); }
public void setProperty(Row row, int column) { // create cell if it does not exist Cell cell = CellUtil.getCell(row, column); CellUtil.setCellStyleProperty(cell, _propertyName, _propertyValue); } }
/** * Take a cell, and apply a font to it * * @param cell the cell to set the alignment for * @param font The Font that you want to set. * @throws IllegalArgumentException if <tt>font</tt> and <tt>cell</tt> do not belong to the same workbook */ public static void setFont(Cell cell, Font font) { // Check if font belongs to workbook Workbook wb = cell.getSheet().getWorkbook(); final int fontIndex = font.getIndexAsInt(); if (!wb.getFontAt(fontIndex).equals(font)) { throw new IllegalArgumentException("Font does not belong to this workbook"); } // Check if cell belongs to workbook // (checked in setCellStyleProperty) setCellStyleProperty(cell, FONT, fontIndex); }
/** * Take a cell, and align it. * * This is superior to cell.getCellStyle().setAlignment(align) because * this method will not modify the CellStyle object that may be referenced * by multiple cells. Instead, this method will search for existing CellStyles * that match the desired CellStyle, creating a new CellStyle with the desired * style if no match exists. * * @param cell the cell to set the alignment for * @param align the horizontal alignment to use. * * @see HorizontalAlignment for alignment options * @since POI 3.15 beta 3 */ public static void setAlignment(Cell cell, HorizontalAlignment align) { setCellStyleProperty(cell, ALIGNMENT, align); }
/** * This method attempt to find an already existing HSSFCellStyle that matches * what you want the style to be. If it does not find the style, then it * creates a new one. If it does create a new one, then it applies the * propertyName and propertyValue to the style. This is necessary because * Excel has an upper limit on the number of Styles that it supports. * *@param workbook The workbook that is being worked with. *@param propertyName The name of the property that is to be * changed. *@param propertyValue The value of the property that is to be * changed. *@param cell The cell that needs it's style changes */ public static void setCellStyleProperty(HSSFCell cell, HSSFWorkbook workbook, String propertyName, Object propertyValue) { CellUtil.setCellStyleProperty(cell, workbook, propertyName, propertyValue); }
/** * This method attempt to find an already existing HSSFCellStyle that matches * what you want the style to be. If it does not find the style, then it * creates a new one. If it does create a new one, then it applies the * propertyName and propertyValue to the style. This is necessary because * Excel has an upper limit on the number of Styles that it supports. * *@param workbook The workbook that is being worked with. *@param propertyName The name of the property that is to be * changed. *@param propertyValue The value of the property that is to be * changed. *@param cell The cell that needs it's style changes */ public static void setCellStyleProperty(HSSFCell cell, HSSFWorkbook workbook, String propertyName, Object propertyValue) { CellUtil.setCellStyleProperty(cell, workbook, propertyName, propertyValue); }
/** * Take a cell, and vertically align it. * * This is superior to cell.getCellStyle().setVerticalAlignment(align) because * this method will not modify the CellStyle object that may be referenced * by multiple cells. Instead, this method will search for existing CellStyles * that match the desired CellStyle, creating a new CellStyle with the desired * style if no match exists. * * @param cell the cell to set the alignment for * @param align the vertical alignment to use. * * @see VerticalAlignment for alignment options * @since POI 3.15 beta 3 */ public static void setVerticalAlignment(Cell cell, VerticalAlignment align) { setCellStyleProperty(cell, VERTICAL_ALIGNMENT, align); }
/** * Take a cell, and align it. * *@param cell the cell to set the alignment for *@param workbook The workbook that is being worked with. *@param align the column alignment to use. * * @see CellStyle for alignment options */ public static void setAlignment(Cell cell, Workbook workbook, short align) { setCellStyleProperty(cell, workbook, ALIGNMENT, Short.valueOf(align)); }
/** * Take a cell, and align it. * *@param cell the cell to set the alignment for *@param workbook The workbook that is being worked with. *@param align the column alignment to use. * * @see CellStyle for alignment options */ public static void setAlignment(Cell cell, Workbook workbook, short align) { setCellStyleProperty(cell, workbook, ALIGNMENT, Short.valueOf(align)); }
public void setProperty(Row row, int column) { // create cell if it does not exist Cell cell = CellUtil.getCell(row, column); CellUtil.setCellStyleProperty(cell, _propertyName, _propertyValue); } }
/** * Take a cell, and apply a font to it * *@param cell the cell to set the alignment for *@param workbook The workbook that is being worked with. *@param font The Font that you want to set... */ public static void setFont(Cell cell, Workbook workbook, Font font) { setCellStyleProperty(cell, workbook, FONT, font.getIndex()); }
public void setProperty(Row row, int column) { Cell cell = CellUtil.getCell(row, column); CellUtil.setCellStyleProperty(cell, _workbook, _propertyName, _propertyValue); } }
public void setProperty(Row row, int column) { Cell cell = CellUtil.getCell(row, column); CellUtil.setCellStyleProperty(cell, _workbook, _propertyName, _propertyValue); } }
/** * Take a cell, and apply a font to it * *@param cell the cell to set the alignment for *@param workbook The workbook that is being worked with. *@param font The Font that you want to set... */ public static void setFont(Cell cell, Workbook workbook, Font font) { setCellStyleProperty(cell, workbook, FONT, font.getIndex()); }
public void setCellAlignment(int col, int row, HorizontalAlignment alignment) { Sheet sheet = getSheet(); Cell cell = PoiExcelHelper.getOrCreateCell(col, row, sheet); CellUtil.setCellStyleProperty(cell, CellUtil.ALIGNMENT, alignment); }
public void setCellIndent(int col, int row, int indent) { Sheet sheet = getSheet(); Cell cell = PoiExcelHelper.getOrCreateCell(col, row, sheet); CellUtil.setCellStyleProperty(cell, CellUtil.INDENTION, (short) indent); }
/** * Take a cell, and apply a font to it * * @param cell the cell to set the alignment for * @param font The Font that you want to set. * @throws IllegalArgumentException if <tt>font</tt> and <tt>cell</tt> do not belong to the same workbook */ public static void setFont(Cell cell, Font font) { // Check if font belongs to workbook Workbook wb = cell.getSheet().getWorkbook(); final int fontIndex = font.getIndexAsInt(); if (!wb.getFontAt(fontIndex).equals(font)) { throw new IllegalArgumentException("Font does not belong to this workbook"); } // Check if cell belongs to workbook // (checked in setCellStyleProperty) setCellStyleProperty(cell, FONT, fontIndex); }