/** * Opens up the Shared Strings Table, parses it, and * returns a handy object for working with * shared strings. */ public SharedStringsTable getSharedStringsTable() throws IOException, InvalidFormatException { ArrayList<PackagePart> parts = pkg.getPartsByContentType(XSSFRelation.SHARED_STRINGS.getContentType()); return parts.size() == 0 ? null : new SharedStringsTable(parts.get(0)); }
/** * Are we a normal workbook (.xlsx), or a * macro enabled workbook (.xlsm)? */ public boolean isMacroEnabled() { return getPackagePart().getContentType().equals(XSSFRelation.MACROS_WORKBOOK.getContentType()); }
protected void beforeDocumentRead() { // Ensure it isn't a XLSB file, which we don't support if (getCorePart().getContentType().equals(XSSFRelation.XLSB_BINARY_WORKBOOK.getContentType())) { throw new XLSBUnsupportedException(); } // Create arrays for parts attached to the workbook itself pivotTables = new ArrayList<>(); pivotCaches = new ArrayList<>(); }
/** * Opens up the Styles Table, parses it, and * returns a handy object for working with cell styles */ public StylesTable getStylesTable() throws IOException, InvalidFormatException { ArrayList<PackagePart> parts = pkg.getPartsByContentType(XSSFRelation.STYLES.getContentType()); if (parts.size() == 0) return null; // Create the Styles Table, and associate the Themes if present StylesTable styles = new StylesTable(parts.get(0)); parts = pkg.getPartsByContentType(XSSFRelation.THEME.getContentType()); if (parts.size() != 0) { styles.setTheme(new ThemesTable(parts.get(0))); } return styles; }
/** * * @param pkg The {@link OPCPackage} to use as basis for the shared-strings table. * @param includePhoneticRuns whether or not to concatenate phoneticRuns onto the shared string * @since POI 3.14-Beta3 * @throws IOException If reading the data from the package fails. * @throws SAXException if parsing the XML data fails. */ public ReadOnlySharedStringsTable(OPCPackage pkg, boolean includePhoneticRuns) throws IOException, SAXException { this.includePhoneticRuns = includePhoneticRuns; ArrayList<PackagePart> parts = pkg.getPartsByContentType(XSSFRelation.SHARED_STRINGS.getContentType()); // Some workbooks have no shared strings table. if (parts.size() > 0) { PackagePart sstPart = parts.get(0); readFrom(sstPart.getInputStream()); } }
if ( rel.getContentType().equals( contentType ) ) { if (getPreferEventExtractor()) { return new XSSFEventBasedExcelExtractor(pkg); if (rel.getContentType().equals(contentType)) { return new XSSFBEventBasedExcelExtractor(pkg);
int tableNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.TABLE.getContentType()).size() + 1; while(loop) { loop = false; for (PackagePart packagePart : getPackagePart().getPackage().getPartsByContentType(XSSFRelation.TABLE.getContentType())) { String fileName = XSSFRelation.TABLE.getFileName(tableNumber); if(fileName.equals(packagePart.getPartName().getName())) {
/** * Creates a chart. * * @param anchor * the client anchor describes how this chart is attached to the * sheet. * @return the newly created chart * @see org.apache.poi.xssf.usermodel.XSSFDrawing#createChart(ClientAnchor) */ public XSSFChart createChart(XSSFClientAnchor anchor) { int chartNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.CHART.getContentType()) .size() + 1; RelationPart rp = createRelationship(XSSFRelation.CHART, XSSFFactory.getInstance(), chartNumber, false); XSSFChart chart = rp.getDocumentPart(); String chartRelId = rp.getRelationship().getId(); XSSFGraphicFrame frame = createGraphicFrame(anchor); frame.setChart(chart, chartRelId); frame.getCTGraphicalObjectFrame().setXfrm(createXfrm(anchor)); return chart; }
/** * Create a new SpreadsheetML drawing. If this sheet already contains a drawing - return that. * * @return a SpreadsheetML drawing */ @Override public XSSFDrawing createDrawingPatriarch() { CTDrawing ctDrawing = getCTDrawing(); if (ctDrawing != null) { return getDrawingPatriarch(); } // Default drawingNumber = #drawings.size() + 1 int drawingNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.DRAWINGS.getContentType()).size() + 1; drawingNumber = getNextPartNumber(XSSFRelation.DRAWINGS, drawingNumber); RelationPart rp = createRelationship(XSSFRelation.DRAWINGS, XSSFFactory.getInstance(), drawingNumber, false); XSSFDrawing drawing = rp.getDocumentPart(); String relId = rp.getRelationship().getId(); //add CT_Drawing element which indicates that this sheet contains drawing components built on the drawingML platform. //The relationship Id references the part containing the drawingML definitions. ctDrawing = worksheet.addNewDrawing(); ctDrawing.setId(relId); // Return the newly created drawing return drawing; }
if(autoCreate) { int drawingNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.VML_DRAWINGS.getContentType()).size() + 1; RelationPart rp = createRelationship(XSSFRelation.VML_DRAWINGS, XSSFFactory.getInstance(), drawingNumber, false); drawing = rp.getDocumentPart();
public static BufferedStringsTable getSharedStringsTable(File tmp, int cacheSize, OPCPackage pkg) throws IOException { List<PackagePart> parts = pkg.getPartsByContentType(XSSFRelation.SHARED_STRINGS.getContentType()); return parts.size() == 0 ? null : new BufferedStringsTable(parts.get(0), tmp, cacheSize); }
/** * Opens up the Shared Strings Table, parses it, and * returns a handy object for working with * shared strings. */ public SharedStringsTable getSharedStringsTable() throws IOException, InvalidFormatException { ArrayList<PackagePart> parts = pkg.getPartsByContentType( XSSFRelation.SHARED_STRINGS.getContentType()); return parts.size() == 0 ? null : new SharedStringsTable(parts.get(0), null); }
/** * Opens up the Shared Strings Table, parses it, and * returns a handy object for working with * shared strings. */ public SharedStringsTable getSharedStringsTable() throws IOException, InvalidFormatException { ArrayList<PackagePart> parts = pkg.getPartsByContentType(XSSFRelation.SHARED_STRINGS.getContentType()); return parts.size() == 0 ? null : new SharedStringsTable(parts.get(0)); }
/** * Are we a normal workbook (.xlsx), or a * macro enabled workbook (.xlsm)? */ public boolean isMacroEnabled() { return getPackagePart().getContentType().equals(XSSFRelation.MACROS_WORKBOOK.getContentType()); }
/** * Are we a normal workbook (.xlsx), or a * macro enabled workbook (.xlsm)? */ public boolean isMacroEnabled() { return getPackagePart().getContentType().equals(XSSFRelation.MACROS_WORKBOOK.getContentType()); }
protected void beforeDocumentRead() { // Ensure it isn't a XLSB file, which we don't support if (getCorePart().getContentType().equals(XSSFRelation.XLSB_BINARY_WORKBOOK.getContentType())) { throw new XLSBUnsupportedException(); } // Create arrays for parts attached to the workbook itself pivotTables = new ArrayList<>(); pivotCaches = new ArrayList<>(); }
/** * Opens up the Styles Table, parses it, and * returns a handy object for working with cell styles */ public StylesTable getStylesTable() throws IOException, InvalidFormatException { ArrayList<PackagePart> parts = pkg.getPartsByContentType( XSSFRelation.STYLES.getContentType()); if(parts.size() == 0) return null; // Create the Styles Table, and associate the Themes if present StylesTable styles = new StylesTable(parts.get(0), null); parts = pkg.getPartsByContentType( XSSFRelation.THEME.getContentType()); if(parts.size() != 0) { styles.setTheme(new ThemesTable(parts.get(0), null)); } return styles; }
/** * Opens up the Styles Table, parses it, and * returns a handy object for working with cell styles */ public StylesTable getStylesTable() throws IOException, InvalidFormatException { ArrayList<PackagePart> parts = pkg.getPartsByContentType(XSSFRelation.STYLES.getContentType()); if (parts.size() == 0) return null; // Create the Styles Table, and associate the Themes if present StylesTable styles = new StylesTable(parts.get(0)); parts = pkg.getPartsByContentType(XSSFRelation.THEME.getContentType()); if (parts.size() != 0) { styles.setTheme(new ThemesTable(parts.get(0))); } return styles; }
/** * Creates a chart. * @param anchor the client anchor describes how this chart is attached to * the sheet. * @return the newly created chart * @see org.apache.poi.xssf.usermodel.XSSFDrawing#createChart(ClientAnchor) */ public XSSFChart createChart(XSSFClientAnchor anchor) { int chartNumber = getPackagePart().getPackage(). getPartsByContentType(XSSFRelation.CHART.getContentType()).size() + 1; XSSFChart chart = (XSSFChart) createRelationship( XSSFRelation.CHART, XSSFFactory.getInstance(), chartNumber); String chartRelId = chart.getPackageRelationship().getId(); XSSFGraphicFrame frame = createGraphicFrame(anchor); frame.setChart(chart, chartRelId); return chart; }
/** * Creates a new Table, and associates it with this Sheet */ public XSSFTable createTable() { if(! worksheet.isSetTableParts()) { worksheet.addNewTableParts(); } CTTableParts tblParts = worksheet.getTableParts(); CTTablePart tbl = tblParts.addNewTablePart(); // Table numbers need to be unique in the file, not just // unique within the sheet. Find the next one int tableNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.TABLE.getContentType()).size() + 1; XSSFTable table = (XSSFTable)createRelationship(XSSFRelation.TABLE, XSSFFactory.getInstance(), tableNumber); tbl.setId(table.getPackageRelationship().getId()); tables.put(tbl.getId(), table); return table; }