/** * Get the cell style by index. * * @param idx * @return */ public CTCellStyle getStyleByIndex(long idx) { if (this.getJaxbElement().getCellStyles()!=null) { return this.getJaxbElement().getCellStyles().getCellStyle().get((int)idx); } return null; }
XSSFWorkbook wb = new XSSFWorkbook(...); StylesTable stylesTable = wb.getStylesSource(); CTStylesheet ct = stylesTable.getCTStylesheet(); CTCellStyles cellStyles = ct.getCellStyles(); // Prints the count from: <cellStyles count="3516"> System.out.println("Number of CT styles: " + cellStyles.getCount()); for (CTCellStyle style : cellStyles.getCellStyleList()) { // Prints the name // Example: <cellStyle name="Note 2" xfId="3506"/> // Prints: Note 2 System.out.println(style.getName()); }
/** * Get the cell style by index. * * @param idx * @return */ public CTCellStyle getStyleByIndex(long idx) { if (this.getJaxbElement().getCellStyles()!=null) { return this.getJaxbElement().getCellStyles().getCellStyle().get((int)idx); } return null; }
public StyleSheet(CTStylesheet ctStylesheet) { this.ctStylesheet = ctStylesheet; CTCellStyles ctCellStyles = ctStylesheet.getCellStyles(); CTCellStyleXfs ctCellStyleXfs = ctStylesheet.getCellStyleXfs(); CTCellXfs ctCellXfs = ctStylesheet.getCellXfs();
public StyleSheet(CTStylesheet ctStylesheet) { this.ctStylesheet = ctStylesheet; CTCellStyles ctCellStyles = ctStylesheet.getCellStyles(); CTCellStyleXfs ctCellStyleXfs = ctStylesheet.getCellStyleXfs(); CTCellXfs ctCellXfs = ctStylesheet.getCellXfs();
stylesheet.getCellXfs().getXf().add(generateCTXf(1l, 0l, null, 0l, 0l, cellAlignment, true)); stylesheet.setCellStyles(new CTCellStyles()); stylesheet.getCellStyles().setCount(1L); CTCellStyle cellStyle = new CTCellStyle(); cellStyle.setName("myStyle"); cellStyle.setXfId(0L); cellStyle.setCustomBuiltin(true); stylesheet.getCellStyles().getCellStyle().add(cellStyle); stylesheet.setCellStyleXfs(new CTCellStyleXfs()); stylesheet.getCellStyleXfs().setCount(1L);