本文整理了Java中org.apache.poi.xwpf.usermodel.XWPFDocument.createRelationship()
方法的一些代码示例,展示了XWPFDocument.createRelationship()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XWPFDocument.createRelationship()
方法的具体详情如下:
包路径:org.apache.poi.xwpf.usermodel.XWPFDocument
类名称:XWPFDocument
方法名:createRelationship
暂无
代码示例来源: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
/**
* Creates an empty numbering if one does not already exist and sets the numbering member
*
* @return numbering
*/
public XWPFNumbering createNumbering() {
if (numbering == null) {
NumberingDocument numberingDoc = NumberingDocument.Factory.newInstance();
XWPFRelation relation = XWPFRelation.NUMBERING;
int i = getRelationIndex(relation);
XWPFNumbering wrapper = (XWPFNumbering) createRelationship(relation, XWPFFactory.getInstance(), i);
wrapper.setNumbering(numberingDoc.addNewNumbering());
numbering = wrapper;
}
return numbering;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
public XWPFEndnotes createEndnotes() {
if (endnotes == null) {
EndnotesDocument endnotesDoc = EndnotesDocument.Factory.newInstance();
XWPFRelation relation = XWPFRelation.ENDNOTE;
int i = getRelationIndex(relation);
XWPFEndnotes wrapper = (XWPFEndnotes) createRelationship(relation, XWPFFactory.getInstance(), i);
wrapper.setEndnotes(endnotesDoc.addNewEndnotes());
wrapper.setIdManager(footnoteIdManager);
endnotes = wrapper;
}
return endnotes;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Create a new CTWorkbook with all values set to default
*/
@Override
protected void onDocumentCreate() {
ctDocument = CTDocument1.Factory.newInstance();
ctDocument.addNewBody();
settings = (XWPFSettings) createRelationship(XWPFRelation.SETTINGS, XWPFFactory.getInstance());
POIXMLProperties.ExtendedProperties expProps = getProperties().getExtendedProperties();
expProps.getUnderlyingProperties().setApplication(DOCUMENT_CREATOR);
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Creates an empty footnotes element for the document if one does not already exist
*
* @return footnotes
*/
public XWPFFootnotes createFootnotes() {
if (footnotes == null) {
FootnotesDocument footnotesDoc = FootnotesDocument.Factory.newInstance();
XWPFRelation relation = XWPFRelation.FOOTNOTE;
int i = getRelationIndex(relation);
XWPFFootnotes wrapper = (XWPFFootnotes) createRelationship(relation, XWPFFactory.getInstance(), i);
wrapper.setFootnotes(footnotesDoc.addNewFootnotes());
wrapper.setIdManager(this.footnoteIdManager);
footnotes = wrapper;
}
return footnotes;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* This method is used to create template for chart XML
* no need to read MS-Word file and modify charts
*
* @param width width of chart in document
* @param height height of chart in document
* @return This method return object of XWPFChart
* @throws InvalidFormatException
* @throws IOException
* @since POI 4.0.0
*/
public XWPFChart createChart(int width, int height) throws InvalidFormatException, IOException {
//get chart number
int chartNumber = getNextPartNumber(XWPFRelation.CHART, charts.size() + 1);
//create relationship in document for new chart
RelationPart rp = createRelationship(
XWPFRelation.CHART, XWPFFactory.getInstance(), chartNumber, false);
// initialize xwpfchart object
XWPFChart xwpfChart = rp.getDocumentPart();
xwpfChart.setChartIndex(chartNumber);
xwpfChart.attach(rp.getRelationship().getId(), createParagraph().createRun());
xwpfChart.setChartBoundingBox(width, height);
//add chart object to chart list
charts.add(xwpfChart);
return xwpfChart;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
xwpfPicData = (XWPFPictureData) createRelationship(relDesc, XWPFFactory.getInstance(), idx);
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Creates a new header of the specified type, to which the
* supplied (and previously unattached!) paragraphs are
* added to.
*/
public XWPFHeader createHeader(Enum type, XWPFParagraph[] pars) {
XWPFHeader header = getHeader(type);
if (header == null) {
HdrDocument hdrDoc = HdrDocument.Factory.newInstance();
XWPFRelation relation = XWPFRelation.HEADER;
int i = getRelationIndex(relation);
XWPFHeader wrapper = (XWPFHeader) doc.createRelationship(relation,
XWPFFactory.getInstance(), i);
wrapper.setXWPFDocument(doc);
CTHdrFtr hdr = buildHdr(type, wrapper, pars);
wrapper.setHeaderFooter(hdr);
hdrDoc.setHdr(hdr);
assignHeader(wrapper, type);
header = wrapper;
}
return header;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Creates a new footer of the specified type, to which the
* supplied (and previously unattached!) paragraphs are
* added to.
*/
public XWPFFooter createFooter(Enum type, XWPFParagraph[] pars) {
XWPFFooter footer = getFooter(type);
if (footer == null) {
FtrDocument ftrDoc = FtrDocument.Factory.newInstance();
XWPFRelation relation = XWPFRelation.FOOTER;
int i = getRelationIndex(relation);
XWPFFooter wrapper = (XWPFFooter) doc.createRelationship(relation,
XWPFFactory.getInstance(), i);
wrapper.setXWPFDocument(doc);
CTHdrFtr ftr = buildFtr(type, wrapper, pars);
wrapper.setHeaderFooter(ftr);
ftrDoc.setFtr(ftr);
assignFooter(wrapper, type);
footer = wrapper;
}
return footer;
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* Creates an empty footnotes element for the document if one does not already exist
* @return footnotes
*/
public XWPFFootnotes createFootnotes() {
if(footnotes == null) {
FootnotesDocument footnotesDoc = FootnotesDocument.Factory.newInstance();
XWPFRelation relation = XWPFRelation.FOOTNOTE;
int i = getRelationIndex(relation);
XWPFFootnotes wrapper = (XWPFFootnotes)createRelationship(relation, XWPFFactory.getInstance(), i);
wrapper.setFootnotes(footnotesDoc.addNewFootnotes());
footnotes = wrapper;
}
return footnotes;
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* Creates an empty numbering if one does not already exist and sets the numbering member
* @return numbering
*/
public XWPFNumbering createNumbering() {
if(numbering == null) {
NumberingDocument numberingDoc = NumberingDocument.Factory.newInstance();
XWPFRelation relation = XWPFRelation.NUMBERING;
int i = getRelationIndex(relation);
XWPFNumbering wrapper = (XWPFNumbering)createRelationship(relation, XWPFFactory.getInstance(), i);
wrapper.setNumbering(numberingDoc.addNewNumbering());
numbering = wrapper;
}
return numbering;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* Creates an empty numbering if one does not already exist and sets the numbering member
*
* @return numbering
*/
public XWPFNumbering createNumbering() {
if (numbering == null) {
NumberingDocument numberingDoc = NumberingDocument.Factory.newInstance();
XWPFRelation relation = XWPFRelation.NUMBERING;
int i = getRelationIndex(relation);
XWPFNumbering wrapper = (XWPFNumbering) createRelationship(relation, XWPFFactory.getInstance(), i);
wrapper.setNumbering(numberingDoc.addNewNumbering());
numbering = wrapper;
}
return numbering;
}
代码示例来源: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.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
public XWPFEndnotes createEndnotes() {
if (endnotes == null) {
EndnotesDocument endnotesDoc = EndnotesDocument.Factory.newInstance();
XWPFRelation relation = XWPFRelation.ENDNOTE;
int i = getRelationIndex(relation);
XWPFEndnotes wrapper = (XWPFEndnotes) createRelationship(relation, XWPFFactory.getInstance(), i);
wrapper.setEndnotes(endnotesDoc.addNewEndnotes());
wrapper.setIdManager(footnoteIdManager);
endnotes = wrapper;
}
return endnotes;
}
代码示例来源: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
/**
* Create a new CTWorkbook with all values set to default
*/
@Override
protected void onDocumentCreate() {
ctDocument = CTDocument1.Factory.newInstance();
ctDocument.addNewBody();
settings = (XWPFSettings) createRelationship(XWPFRelation.SETTINGS, XWPFFactory.getInstance());
POIXMLProperties.ExtendedProperties expProps = getProperties().getExtendedProperties();
expProps.getUnderlyingProperties().setApplication(DOCUMENT_CREATOR);
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* Create a new CTWorkbook with all values set to default
*/
@Override
protected void onDocumentCreate() {
ctDocument = CTDocument1.Factory.newInstance();
ctDocument.addNewBody();
settings = (XWPFSettings) createRelationship(XWPFRelation.SETTINGS,XWPFFactory.getInstance());
POIXMLProperties.ExtendedProperties expProps = getProperties().getExtendedProperties();
expProps.getUnderlyingProperties().setApplication(DOCUMENT_CREATOR);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* Creates an empty footnotes element for the document if one does not already exist
*
* @return footnotes
*/
public XWPFFootnotes createFootnotes() {
if (footnotes == null) {
FootnotesDocument footnotesDoc = FootnotesDocument.Factory.newInstance();
XWPFRelation relation = XWPFRelation.FOOTNOTE;
int i = getRelationIndex(relation);
XWPFFootnotes wrapper = (XWPFFootnotes) createRelationship(relation, XWPFFactory.getInstance(), i);
wrapper.setFootnotes(footnotesDoc.addNewFootnotes());
wrapper.setIdManager(this.footnoteIdManager);
footnotes = wrapper;
}
return footnotes;
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
public XWPFFooter createFooter(Enum type, XWPFParagraph[] pars) throws IOException {
XWPFRelation relation = XWPFRelation.FOOTER;
String pStyle = "Footer";
int i = getRelationIndex(relation);
FtrDocument ftrDoc = FtrDocument.Factory.newInstance();
XWPFFooter wrapper = (XWPFFooter)doc.createRelationship(relation, XWPFFactory.getInstance(), i);
CTHdrFtr ftr = buildFtr(type, pStyle, wrapper, pars);
wrapper.setHeaderFooter(ftr);
OutputStream outputStream = wrapper.getPackagePart().getOutputStream();
ftrDoc.setFtr(ftr);
XmlOptions xmlOptions = commit(wrapper);
assignFooter(wrapper, type);
ftrDoc.save(outputStream, xmlOptions);
outputStream.close();
return wrapper;
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
public XWPFHeader createHeader(Enum type, XWPFParagraph[] pars) throws IOException {
XWPFRelation relation = XWPFRelation.HEADER;
String pStyle = "Header";
int i = getRelationIndex(relation);
HdrDocument hdrDoc = HdrDocument.Factory.newInstance();
XWPFHeader wrapper = (XWPFHeader)doc.createRelationship(relation, XWPFFactory.getInstance(), i);
CTHdrFtr hdr = buildHdr(type, pStyle, wrapper, pars);
wrapper.setHeaderFooter(hdr);
OutputStream outputStream = wrapper.getPackagePart().getOutputStream();
hdrDoc.setHdr(hdr);
XmlOptions xmlOptions = commit(wrapper);
assignHeader(wrapper, type);
hdrDoc.save(outputStream, xmlOptions);
outputStream.close();
return wrapper;
}
内容来源于网络,如有侵权,请联系作者删除!