public static org.xlsx4j.sml.ObjectFactory getsmlObjectFactory() { if (smlObjectFactory==null) { smlObjectFactory = new org.xlsx4j.sml.ObjectFactory(); } return smlObjectFactory; } }
Context.getsmlObjectFactory().createWorkbook() ); xlsPack.addTargetPart(xlsPack.wb); BookViews bookview = Context.getsmlObjectFactory().createBookViews(); CTBookView ctBookview = Context.getsmlObjectFactory().createCTBookView(); bookview.getWorkbookView().add(ctBookview); xlsPack.wb.getContents().setBookViews(bookview); Context.getsmlObjectFactory().createSheets() );
protected CTStylesheet generateStyleSheet(ObjectFactory factory) { CTStylesheet stylesheet = factory.createCTStylesheet(); CTBorders borders = factory.createCTBorders(); CTBorderPr borderPr = factory.createCTBorderPr(); borderPr.setStyle(STBorderStyle.THIN); CTColor borderColor = new CTColor(); borderColor.setIndexed(64l); borderPr.setColor(borderColor); borders.getBorder().add(generateBorder(factory, factory.createCTBorderPr())); borders.getBorder().add(generateBorder(factory, borderPr)); borders.setCount(2L); stylesheet.setFills(factory.createCTFills()); CTFill fill = factory.createCTFill(); CTPatternFill ctPatternFill = new CTPatternFill(); ctPatternFill.setPatternType(STPatternType.NONE); stylesheet.setFonts(factory.createCTFonts()); CTFont font = new CTFont(); CTFontSize fdrSize = new CTFontSize(); fdrSize.setVal(12); JAXBElement<CTFontSize> element19 = factory.createCTFontSz(fdrSize); font.getNameOrCharsetOrFamily().add(element19); JAXBElement<CTColor> element20 = factory.createCTFontColor(fdrColor); font.getNameOrCharsetOrFamily().add(element20); JAXBElement<CTFontName> element21 = factory.createCTFontName(fdrFontName); font.getNameOrCharsetOrFamily().add(element21); stylesheet.getFonts().getFont().add(font);
SheetData sheetData = sheet.getJaxbElement().getSheetData(); org.xlsx4j.sml.ObjectFactory factory = org.xlsx4j.jaxb.Context.getsmlObjectFactory(); CTCalcPr ctCalcPr = factory.createCTCalcPr(); ctCalcPr.setCalcMode(STCalcMode.AUTO); pkg.getWorkbookPart().getJaxbElement().setCalcPr(ctCalcPr); DefinedNames definedNames = factory.createDefinedNames(); long rowNum = 1; //first row of sheet is '1' long startedRowForRegion; startedRowForRegion = rowNum; for (RegionProperty regionProperty : reportRegion.getRegionProperties()) { Row row = factory.createRow(); row.setR(rowNum); row.getC().add(createCell(factory, regionProperty.getHierarchicalLocalizedNameExceptRoot() + ":", 1, rowNum)); Cols cols = factory.createCols(); for (int i = 0; i < maxColCount; i++) { Col col = factory.createCol(); col.setMin(i + 1); col.setMax(i + 1);
public Row createRow(org.xlsx4j.sml.ObjectFactory factory, String stringContent, int colNum, long rowNum) { Row row = factory.createRow(); row.setR(rowNum); Cell cell = createCell(factory, stringContent, colNum, rowNum); cell.setS(1L); row.getC().add(cell); return row; }
/** * XLSX document does not store empty cells and it might be an issue for formula calculations and etc. * So we need to create fake template cell for each empty cell. */ protected void createFakeTemplateCellsForEmptyOnes(Range oneRowRange, Map<CellReference, Cell> cellsForOneRowRange, List<Cell> templateCells) { if (oneRowRange.toCellReferences().size() != templateCells.size()) { final HashBiMap<CellReference, Cell> referencesToCells = HashBiMap.create(cellsForOneRowRange); for (CellReference cellReference : oneRowRange.toCellReferences()) { if (!cellsForOneRowRange.containsKey(cellReference)) { Cell newCell = Context.getsmlObjectFactory().createCell(); newCell.setV(null); newCell.setT(STCellType.STR); newCell.setR(cellReference.toReference()); templateCells.add(newCell); referencesToCells.put(cellReference, newCell); } } templateCells.sort((o1, o2) -> { CellReference cellReference1 = referencesToCells.inverse().get(o1); CellReference cellReference2 = referencesToCells.inverse().get(o2); return cellReference1.compareTo(cellReference2); }); } }
protected CTBorder generateBorder(org.xlsx4j.sml.ObjectFactory factory, CTBorderPr borderPr) { CTBorder border = factory.createCTBorder(); border.setBottom(borderPr); border.setTop(borderPr); border.setLeft(borderPr); border.setRight(borderPr); return border; }
protected Row createNewRow(Worksheet resultSheet) { Row newRow = Context.getsmlObjectFactory().createRow(); Long currentRow = lastRowForSheet.get(resultSheet); currentRow = currentRow != null ? currentRow : 0; currentRow++; newRow.setR(currentRow); lastRowForSheet.put(resultSheet, currentRow); resultSheet.getSheetData().getRow().add(newRow); newRow.setParent(resultSheet.getSheetData()); return newRow; }
/** * XLSX document does not store empty cells and it might be an issue for formula calculations and etc. * So we need to create fake template cell for each empty cell. */ protected void createFakeTemplateCellsForEmptyOnes(Range oneRowRange, Map<CellReference, Cell> cellsForOneRowRange, List<Cell> templateCells) { if (oneRowRange.toCellReferences().size() != templateCells.size()) { final HashBiMap<CellReference, Cell> referencesToCells = HashBiMap.create(cellsForOneRowRange); for (CellReference cellReference : oneRowRange.toCellReferences()) { if (!cellsForOneRowRange.containsKey(cellReference)) { Cell newCell = Context.getsmlObjectFactory().createCell(); newCell.setV(null); newCell.setT(STCellType.STR); newCell.setR(cellReference.toReference()); templateCells.add(newCell); referencesToCells.put(cellReference, newCell); } } Collections.sort(templateCells, new Comparator<Cell>() { @Override public int compare(Cell o1, Cell o2) { CellReference cellReference1 = referencesToCells.inverse().get(o1); CellReference cellReference2 = referencesToCells.inverse().get(o2); return cellReference1.compareTo(cellReference2); } }); } }
Context.getsmlObjectFactory().createWorkbook() ); xlsPack.addTargetPart(xlsPack.wb); BookViews bookview = Context.getsmlObjectFactory().createBookViews(); CTBookView ctBookview = Context.getsmlObjectFactory().createCTBookView(); bookview.getWorkbookView().add(ctBookview); xlsPack.wb.getContents().setBookViews(bookview); Context.getsmlObjectFactory().createSheets() );
protected Row createNewRow(Worksheet resultSheet) { Row newRow = Context.getsmlObjectFactory().createRow(); Long currentRow = lastRowForSheet.get(resultSheet); currentRow = currentRow != null ? currentRow : 0; currentRow++; newRow.setR(currentRow); lastRowForSheet.put(resultSheet, currentRow); resultSheet.getSheetData().getRow().add(newRow); newRow.setParent(resultSheet.getSheetData()); return newRow; }
public Cell createCell(org.xlsx4j.sml.ObjectFactory factory, String stringContent, int colNum, long rowNum) { Cell cell = factory.createCell(); cell.setT(STCellType.STR); cell.setV(stringContent); cell.setR(CellReference.convertNumToColString(colNum - 1) + "" + rowNum); cell.setS(0L); return cell; }
public static org.xlsx4j.sml.ObjectFactory getsmlObjectFactory() { if (smlObjectFactory==null) { smlObjectFactory = new org.xlsx4j.sml.ObjectFactory(); } return smlObjectFactory; } }