org.apache.poi.xssf.usermodel.XSSFRelation.getContentType()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(84)

本文整理了Java中org.apache.poi.xssf.usermodel.XSSFRelation.getContentType()方法的一些代码示例,展示了XSSFRelation.getContentType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XSSFRelation.getContentType()方法的具体详情如下:
包路径:org.apache.poi.xssf.usermodel.XSSFRelation
类名称:XSSFRelation
方法名:getContentType

XSSFRelation.getContentType介绍

暂无

代码示例

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * 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));
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * Are we a normal workbook (.xlsx), or a
 *  macro enabled workbook (.xlsm)?
 */
public boolean isMacroEnabled() {
  return getPackagePart().getContentType().equals(XSSFRelation.MACROS_WORKBOOK.getContentType());
}

代码示例来源:origin: org.apache.poi/poi-ooxml

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<>();
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * 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;
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 *
 * @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());
  }
}

代码示例来源:origin: org.apache.poi/poi-ooxml

if ( rel.getContentType().equals( contentType ) ) {
  if (getPreferEventExtractor()) {
    return new XSSFEventBasedExcelExtractor(pkg);
if (rel.getContentType().equals(contentType)) {
  return new XSSFBEventBasedExcelExtractor(pkg);

代码示例来源:origin: org.apache.poi/poi-ooxml

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())) {

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * 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;
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * 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;
}

代码示例来源:origin: org.apache.poi/poi-ooxml

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();

代码示例来源:origin: monitorjbl/excel-streaming-reader

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);
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
 * 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);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * 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));
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * Are we a normal workbook (.xlsx), or a
 *  macro enabled workbook (.xlsm)?
 */
public boolean isMacroEnabled() {
  return getPackagePart().getContentType().equals(XSSFRelation.MACROS_WORKBOOK.getContentType());
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
 * Are we a normal workbook (.xlsx), or a
 *  macro enabled workbook (.xlsm)?
 */
public boolean isMacroEnabled() {
  return getPackagePart().getContentType().equals(XSSFRelation.MACROS_WORKBOOK.getContentType());
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

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<>();
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
 * 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;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * 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;
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
 * 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;
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
 * 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;
}

相关文章