/** * If there isn't currently a {@link ThemesTable} for the * current Workbook, then creates one and sets it up. * After this, calls to {@link #getTheme()} won't give null */ public void ensureThemesTable() { if (theme != null) return; setTheme((ThemesTable)workbook.createRelationship(XSSFRelation.THEME, XSSFFactory.getInstance())); }
/** * Adds a picture to the workbook. * * @param pictureData The bytes of the picture * @param format The format of the picture. * * @return the index to this picture (0 based), the added picture can be obtained from {@link #getAllPictures()} . * @see Workbook#PICTURE_TYPE_EMF * @see Workbook#PICTURE_TYPE_WMF * @see Workbook#PICTURE_TYPE_PICT * @see Workbook#PICTURE_TYPE_JPEG * @see Workbook#PICTURE_TYPE_PNG * @see Workbook#PICTURE_TYPE_DIB * @see #getAllPictures() */ @Override public int addPicture(byte[] pictureData, int format) { int imageNumber = getAllPictures().size() + 1; XSSFPictureData img = createRelationship(XSSFPictureData.RELATIONS[format], this.xssfFactory, imageNumber, true).getDocumentPart(); try (OutputStream out = img.getPackagePart().getOutputStream()) { out.write(pictureData); } catch (IOException e){ throw new POIXMLException(e); } pictures.add(img); return imageNumber - 1; }
/** * Create a new CTWorkbook with all values set to default */ private void onWorkbookCreate() { workbook = CTWorkbook.Factory.newInstance(); // don't EVER use the 1904 date system CTWorkbookPr workbookPr = workbook.addNewWorkbookPr(); workbookPr.setDate1904(false); setBookViewsIfMissing(); workbook.addNewSheets(); POIXMLProperties.ExtendedProperties expProps = getProperties().getExtendedProperties(); expProps.getUnderlyingProperties().setApplication(DOCUMENT_CREATOR); sharedStringSource = (SharedStringsTable)createRelationship(XSSFRelation.SHARED_STRINGS, this.xssfFactory); stylesSource = (StylesTable)createRelationship(XSSFRelation.STYLES, this.xssfFactory); stylesSource.setWorkbook(this); namedRanges = new ArrayList<>(); namedRangesByName = new ArrayListValuedHashMap<>(); sheets = new ArrayList<>(); pivotTables = new ArrayList<>(); }
/** * Adds a picture to the workbook. * * @param is The sream to read image from * @param format The format of the picture. * * @return the index to this picture (0 based), the added picture can be obtained from {@link #getAllPictures()} . * @see Workbook#PICTURE_TYPE_EMF * @see Workbook#PICTURE_TYPE_WMF * @see Workbook#PICTURE_TYPE_PICT * @see Workbook#PICTURE_TYPE_JPEG * @see Workbook#PICTURE_TYPE_PNG * @see Workbook#PICTURE_TYPE_DIB * @see #getAllPictures() */ public int addPicture(InputStream is, int format) throws IOException { int imageNumber = getAllPictures().size() + 1; XSSFPictureData img = createRelationship(XSSFPictureData.RELATIONS[format], this.xssfFactory, imageNumber, true).getDocumentPart(); try (OutputStream out = img.getPackagePart().getOutputStream()) { IOUtils.copy(is, out); } pictures.add(img); return imageNumber - 1; }
stylesSource = new StylesTable(); } else { stylesSource = (StylesTable)createRelationship(XSSFRelation.STYLES, this.xssfFactory); sharedStringSource = new SharedStringsTable(); } else { sharedStringSource = (SharedStringsTable)createRelationship(XSSFRelation.SHARED_STRINGS, this.xssfFactory);
RelationPart rp = createRelationship(XSSFRelation.WORKSHEET, this.xssfFactory, sheetNumber, false); XSSFSheet wrapper = rp.getDocumentPart(); wrapper.sheet = sheet;
OutputStream outputStream; if (!opc.containPart(ppName)) { POIXMLDocumentPart relationship = createRelationship(XSSFRelation.VBA_MACROS, this.xssfFactory); outputStream = relationship.getPackagePart().getOutputStream(); } else {
createRelationship(XSSFRelation.PIVOT_CACHE_DEFINITION, XSSFFactory.getInstance(), tableId); String rId = workbook.getRelationId(pivotCacheDefinition);
/** * If there isn't currently a {@link ThemesTable} for the * current Workbook, then creates one and sets it up. * After this, calls to {@link #getTheme()} won't give null */ public void ensureThemesTable() { if (theme != null) return; setTheme((ThemesTable)workbook.createRelationship(XSSFRelation.THEME, XSSFFactory.getInstance())); }
/** * Adds a picture to the workbook. * * @param pictureData The bytes of the picture * @param format The format of the picture. * * @return the index to this picture (0 based), the added picture can be obtained from {@link #getAllPictures()} . * @see Workbook#PICTURE_TYPE_EMF * @see Workbook#PICTURE_TYPE_WMF * @see Workbook#PICTURE_TYPE_PICT * @see Workbook#PICTURE_TYPE_JPEG * @see Workbook#PICTURE_TYPE_PNG * @see Workbook#PICTURE_TYPE_DIB * @see #getAllPictures() */ public int addPicture(byte[] pictureData, int format) { int imageNumber = getAllPictures().size() + 1; XSSFPictureData img = (XSSFPictureData)createRelationship(XSSFPictureData.RELATIONS[format], XSSFFactory.getInstance(), imageNumber, true); try { OutputStream out = img.getPackagePart().getOutputStream(); out.write(pictureData); out.close(); } catch (IOException e){ throw new POIXMLException(e); } pictures.add(img); return imageNumber - 1; }
/** * Adds a picture to the workbook. * * @param pictureData The bytes of the picture * @param format The format of the picture. * * @return the index to this picture (0 based), the added picture can be obtained from {@link #getAllPictures()} . * @see Workbook#PICTURE_TYPE_EMF * @see Workbook#PICTURE_TYPE_WMF * @see Workbook#PICTURE_TYPE_PICT * @see Workbook#PICTURE_TYPE_JPEG * @see Workbook#PICTURE_TYPE_PNG * @see Workbook#PICTURE_TYPE_DIB * @see #getAllPictures() */ @Override public int addPicture(byte[] pictureData, int format) { int imageNumber = getAllPictures().size() + 1; XSSFPictureData img = createRelationship(XSSFPictureData.RELATIONS[format], this.xssfFactory, imageNumber, true).getDocumentPart(); try (OutputStream out = img.getPackagePart().getOutputStream()) { out.write(pictureData); } catch (IOException e){ throw new POIXMLException(e); } pictures.add(img); return imageNumber - 1; }
/** * Adds a picture to the workbook. * * @param is The sream to read image from * @param format The format of the picture. * * @return the index to this picture (0 based), the added picture can be obtained from {@link #getAllPictures()} . * @see Workbook#PICTURE_TYPE_EMF * @see Workbook#PICTURE_TYPE_WMF * @see Workbook#PICTURE_TYPE_PICT * @see Workbook#PICTURE_TYPE_JPEG * @see Workbook#PICTURE_TYPE_PNG * @see Workbook#PICTURE_TYPE_DIB * @see #getAllPictures() */ public int addPicture(InputStream is, int format) throws IOException { int imageNumber = getAllPictures().size() + 1; XSSFPictureData img = (XSSFPictureData)createRelationship(XSSFPictureData.RELATIONS[format], XSSFFactory.getInstance(), imageNumber, true); OutputStream out = img.getPackagePart().getOutputStream(); IOUtils.copy(is, out); out.close(); pictures.add(img); return imageNumber - 1; }
/** * Adds a picture to the workbook. * * @param is The sream to read image from * @param format The format of the picture. * * @return the index to this picture (0 based), the added picture can be obtained from {@link #getAllPictures()} . * @see Workbook#PICTURE_TYPE_EMF * @see Workbook#PICTURE_TYPE_WMF * @see Workbook#PICTURE_TYPE_PICT * @see Workbook#PICTURE_TYPE_JPEG * @see Workbook#PICTURE_TYPE_PNG * @see Workbook#PICTURE_TYPE_DIB * @see #getAllPictures() */ public int addPicture(InputStream is, int format) throws IOException { int imageNumber = getAllPictures().size() + 1; XSSFPictureData img = createRelationship(XSSFPictureData.RELATIONS[format], this.xssfFactory, imageNumber, true).getDocumentPart(); try (OutputStream out = img.getPackagePart().getOutputStream()) { IOUtils.copy(is, out); } pictures.add(img); return imageNumber - 1; }
/** * Create a new CTWorkbook with all values set to default */ private void onWorkbookCreate() { workbook = CTWorkbook.Factory.newInstance(); // don't EVER use the 1904 date system CTWorkbookPr workbookPr = workbook.addNewWorkbookPr(); workbookPr.setDate1904(false); setBookViewsIfMissing(); workbook.addNewSheets(); POIXMLProperties.ExtendedProperties expProps = getProperties().getExtendedProperties(); expProps.getUnderlyingProperties().setApplication(DOCUMENT_CREATOR); sharedStringSource = (SharedStringsTable)createRelationship(XSSFRelation.SHARED_STRINGS, this.xssfFactory); stylesSource = (StylesTable)createRelationship(XSSFRelation.STYLES, this.xssfFactory); stylesSource.setWorkbook(this); namedRanges = new ArrayList<>(); namedRangesByName = new ArrayListValuedHashMap<>(); sheets = new ArrayList<>(); pivotTables = new ArrayList<>(); }
/** * Create a new CTWorkbook with all values set to default */ private void onWorkbookCreate() { workbook = CTWorkbook.Factory.newInstance(); // don't EVER use the 1904 date system CTWorkbookPr workbookPr = workbook.addNewWorkbookPr(); workbookPr.setDate1904(false); CTBookViews bvs = workbook.addNewBookViews(); CTBookView bv = bvs.addNewWorkbookView(); bv.setActiveTab(0); workbook.addNewSheets(); POIXMLProperties.ExtendedProperties expProps = getProperties().getExtendedProperties(); expProps.getUnderlyingProperties().setApplication(DOCUMENT_CREATOR); sharedStringSource = (SharedStringsTable)createRelationship(XSSFRelation.SHARED_STRINGS, XSSFFactory.getInstance()); stylesSource = (StylesTable)createRelationship(XSSFRelation.STYLES, XSSFFactory.getInstance()); namedRanges = new ArrayList<XSSFName>(); sheets = new ArrayList<XSSFSheet>(); }
private void initXMLMap() { ctTable = table.getCTTable(); XSSFWorkbook workbook = getSheet().getWorkbook(); info = workbook.getMapInfo(); if(info == null){ for(POIXMLDocumentPart p : workbook.getRelations()){ if(p instanceof MapInfo) { info = (MapInfo) p; }else if (p instanceof XLSXConnections){ connections = ((XLSXConnections) p).getCTConnections(); } } } if(info == null){ info = (MapInfo) workbook.createRelationship(XSSFRelation.CUSTOM_XML_MAPPINGS, new XLSXFactory()); } if(connections == null){ connections = ((XLSXConnections) workbook.createRelationship(XLSXFactory.CONNECTIONS, new XLSXFactory())).getCTConnections(); } }
stylesSource = new StylesTable(); } else { stylesSource = (StylesTable)createRelationship(XSSFRelation.STYLES, this.xssfFactory); sharedStringSource = new SharedStringsTable(); } else { sharedStringSource = (SharedStringsTable)createRelationship(XSSFRelation.SHARED_STRINGS, this.xssfFactory);
sharedStringSource = (SharedStringsTable)createRelationship(XSSFRelation.SHARED_STRINGS, XSSFFactory.getInstance());
OutputStream outputStream; if (!opc.containPart(ppName)) { POIXMLDocumentPart relationship = createRelationship(XSSFRelation.VBA_MACROS, this.xssfFactory); outputStream = relationship.getPackagePart().getOutputStream(); } else {
createRelationship(XSSFRelation.PIVOT_CACHE_DEFINITION, XSSFFactory.getInstance(), tableId); String rId = workbook.getRelationId(pivotCacheDefinition);