org.apache.poi.xwpf.usermodel.XWPFStyles.setStyles()方法的使用及代码示例

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

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

XWPFStyles.setStyles介绍

[英]Sets the ctStyles
[中]设置CTS样式

代码示例

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

/**
 * Creates an empty styles for the document if one does not already exist
 *
 * @return styles
 */
public XWPFStyles createStyles() {
  if (styles == null) {
    StylesDocument stylesDoc = StylesDocument.Factory.newInstance();
    XWPFRelation relation = XWPFRelation.STYLES;
    int i = getRelationIndex(relation);
    XWPFStyles wrapper = (XWPFStyles) createRelationship(relation, XWPFFactory.getInstance(), i);
    wrapper.setStyles(stylesDoc.addNewStyles());
    styles = wrapper;
  }
  return styles;
}

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

/**
 * Read document
 */
@Override
protected void onDocumentRead() throws IOException {
  StylesDocument stylesDoc;
  InputStream is = getPackagePart().getInputStream();
  try {
    stylesDoc = StylesDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
    setStyles(stylesDoc.getStyles());
    latentStyles = new XWPFLatentStyles(ctStyles.getLatentStyles(), this);
  } catch (XmlException e) {
    throw new POIXMLException("Unable to read styles", e);
  } finally {
    is.close();
  }
}

代码示例来源:origin: stackoverflow.com

XWPFDocument document = new XWPFDocument();
XWPFDocument template = new XWPFDocument(new FileInputStream(new File("Template.dotx")));
XWPFStyles newStyles = document.createStyles();
newStyles.setStyles(template.getStyle());

代码示例来源:origin: stackoverflow.com

XWPFDocument template = new XWPFDocument(new FileInputStream(new File("Template.dotx")));       

XWPFDocument doc = new XWPFDocument();      
// let's copy styles from template to new doc
XWPFStyles newStyles = doc.createStyles();
newStyles.setStyles(template.getStyle());

XWPFParagraph para = doc.createParagraph();
para.setStyle("Heading1");

XWPFRun run = para.createRun();
run.setText("Heading 1");

return doc;

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

/**
 * Creates an empty styles for the document if one does not already exist
 *
 * @return styles
 */
public XWPFStyles createStyles() {
  if (styles == null) {
    StylesDocument stylesDoc = StylesDocument.Factory.newInstance();
    XWPFRelation relation = XWPFRelation.STYLES;
    int i = getRelationIndex(relation);
    XWPFStyles wrapper = (XWPFStyles) createRelationship(relation, XWPFFactory.getInstance(), i);
    wrapper.setStyles(stylesDoc.addNewStyles());
    styles = wrapper;
  }
  return styles;
}

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

/**
 * Creates an empty styles for the document if one does not already exist
 * @return styles
 */
public XWPFStyles createStyles() {
  if(styles == null) {
   StylesDocument stylesDoc = StylesDocument.Factory.newInstance();
   XWPFRelation relation = XWPFRelation.STYLES;
   int i = getRelationIndex(relation);
   XWPFStyles wrapper = (XWPFStyles)createRelationship(relation, XWPFFactory.getInstance(), i);
   wrapper.setStyles(stylesDoc.addNewStyles());
   styles = wrapper;
  }
  return styles;
}

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

/**
 * Read document
 */
@Override
protected void onDocumentRead() throws IOException {
  StylesDocument stylesDoc;
  InputStream is = getPackagePart().getInputStream();
  try {
    stylesDoc = StylesDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
    setStyles(stylesDoc.getStyles());
    latentStyles = new XWPFLatentStyles(ctStyles.getLatentStyles(), this);
  } catch (XmlException e) {
    throw new POIXMLException("Unable to read styles", e);
  } finally {
    is.close();
  }
}

相关文章