当前位置: 首页>>代码示例>>Java>>正文


Java InvalidFormatException类代码示例

本文整理汇总了Java中org.docx4j.openpackaging.exceptions.InvalidFormatException的典型用法代码示例。如果您正苦于以下问题:Java InvalidFormatException类的具体用法?Java InvalidFormatException怎么用?Java InvalidFormatException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InvalidFormatException类属于org.docx4j.openpackaging.exceptions包,在下文中一共展示了InvalidFormatException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createHeaderReference

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
public void createHeaderReference(
		WordprocessingMLPackage wordprocessingMLPackage,
		MainDocumentPart t, ObjectFactory factory, Relationship relationship)
		throws InvalidFormatException {
	List<SectionWrapper> sections = wordprocessingMLPackage
			.getDocumentModel().getSections();
	SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
	// There is always a section wrapper, but it might not contain a sectPr
	if (sectPr == null) {
		sectPr = factory.createSectPr();
		t.addObject(sectPr);
		sections.get(sections.size() - 1).setSectPr(sectPr);
	}
	HeaderReference headerReference = factory.createHeaderReference();
	headerReference.setId(relationship.getId());
	headerReference.setType(HdrFtrRef.DEFAULT);
	sectPr.getEGHdrFtrReferences().add(headerReference);
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:19,代码来源:Docx4J_例子2.java

示例2: createFooterReference

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
public void createFooterReference(
		WordprocessingMLPackage wordprocessingMLPackage,
		MainDocumentPart t, ObjectFactory factory, Relationship relationship)
		throws InvalidFormatException {
	List<SectionWrapper> sections = wordprocessingMLPackage
			.getDocumentModel().getSections();
	SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
	// There is always a section wrapper, but it might not contain a sectPr
	if (sectPr == null) {
		sectPr = factory.createSectPr();
		t.addObject(sectPr);
		sections.get(sections.size() - 1).setSectPr(sectPr);
	}
	FooterReference footerReference = factory.createFooterReference();
	footerReference.setId(relationship.getId());
	footerReference.setType(HdrFtrRef.DEFAULT);
	sectPr.getEGHdrFtrReferences().add(footerReference);
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:19,代码来源:Docx4J_例子2.java

示例3: createHeaderReference

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
 * 创建页眉引用关系
 *
 * @param word
 * @param relationship
 * @throws InvalidFormatException
 */
public static void createHeaderReference(
        WordprocessingMLPackage word,
        Relationship relationship )
        throws InvalidFormatException {
    List<SectionWrapper> sections = word.getDocumentModel().getSections();

    SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
    // There is always a section wrapper, but it might not contain a sectPr
    if (sectPr==null ) {
        sectPr = factory.createSectPr();
        word.getMainDocumentPart().addObject(sectPr);
        sections.get(sections.size() - 1).setSectPr(sectPr);
    }
    HeaderReference headerReference = factory.createHeaderReference();
    headerReference.setId(relationship.getId());
    headerReference.setType(HdrFtrRef.DEFAULT);
    sectPr.getEGHdrFtrReferences().add(headerReference);
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:26,代码来源:Docx4jTest.java

示例4: createFooterReference

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
 * 创建页脚引用关系
 *
 * @param word
 * @param relationship
 * @throws InvalidFormatException
 */
public static void createFooterReference(
        WordprocessingMLPackage word,
        Relationship relationship )
        throws InvalidFormatException {
    List<SectionWrapper> sections = word.getDocumentModel().getSections();

    SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
    // There is always a section wrapper, but it might not contain a sectPr
    if (sectPr==null ) {
        sectPr = factory.createSectPr();
        word.getMainDocumentPart().addObject(sectPr);
        sections.get(sections.size() - 1).setSectPr(sectPr);
    }
    FooterReference footerReference = factory.createFooterReference();
    footerReference.setId(relationship.getId());
    footerReference.setType(HdrFtrRef.DEFAULT);
    sectPr.getEGHdrFtrReferences().add(footerReference);
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:26,代码来源:Docx4jTest.java

示例5: createHeaderReference

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
public void createHeaderReference(  
        WordprocessingMLPackage wordprocessingMLPackage,  
        MainDocumentPart t, ObjectFactory factory, Relationship relationship)  
        throws InvalidFormatException {  
    List<SectionWrapper> sections = wordprocessingMLPackage  
            .getDocumentModel().getSections();  
    SectPr sectPr = sections.get(sections.size() - 1).getSectPr();  
    // There is always a section wrapper, but it might not contain a sectPr  
    if (sectPr == null) {  
        sectPr = factory.createSectPr();  
        t.addObject(sectPr);  
        sections.get(sections.size() - 1).setSectPr(sectPr);  
    }  
    HeaderReference headerReference = factory.createHeaderReference();  
    headerReference.setId(relationship.getId());  
    headerReference.setType(HdrFtrRef.DEFAULT);  
    sectPr.getEGHdrFtrReferences().add(headerReference);  
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:19,代码来源:Docx4J_简单例子2.java

示例6: createFooterReference

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
public void createFooterReference(  
        WordprocessingMLPackage wordprocessingMLPackage,  
        MainDocumentPart t, ObjectFactory factory, Relationship relationship)  
        throws InvalidFormatException {  
    List<SectionWrapper> sections = wordprocessingMLPackage  
            .getDocumentModel().getSections();  
    SectPr sectPr = sections.get(sections.size() - 1).getSectPr();  
    // There is always a section wrapper, but it might not contain a sectPr  
    if (sectPr == null) {  
        sectPr = factory.createSectPr();  
        t.addObject(sectPr);  
        sections.get(sections.size() - 1).setSectPr(sectPr);  
    }  
    FooterReference footerReference = factory.createFooterReference();  
    footerReference.setId(relationship.getId());  
    footerReference.setType(HdrFtrRef.DEFAULT);  
    sectPr.getEGHdrFtrReferences().add(footerReference);  
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:19,代码来源:Docx4J_简单例子2.java

示例7: createFooterReference

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
public static void createFooterReference(
		WordprocessingMLPackage wordprocessingMLPackage,
		Relationship relationship )
		throws InvalidFormatException {

	List<SectionWrapper> sections = wordprocessingMLPackage.getDocumentModel().getSections();
	   
	SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
	// There is always a section wrapper, but it might not contain a sectPr
	if (sectPr==null ) {
		sectPr = objectFactory.createSectPr();
		wordprocessingMLPackage.getMainDocumentPart().addObject(sectPr);
		sections.get(sections.size() - 1).setSectPr(sectPr);
	}

	FooterReference footerReference = objectFactory.createFooterReference();
	footerReference.setId(relationship.getId());
	footerReference.setType(HdrFtrRef.DEFAULT);
	sectPr.getEGHdrFtrReferences().add(footerReference);// add header or
	// footer references
}
 
开发者ID:asposemarketplace,项目名称:Aspose_Java_for_Docx4j,代码行数:22,代码来源:Docx4jFooterCreate.java

示例8: createHeaderReference

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
public static void createHeaderReference(
		WordprocessingMLPackage wordprocessingMLPackage,
		Relationship relationship )
		throws InvalidFormatException {

	List<SectionWrapper> sections = wordprocessingMLPackage.getDocumentModel().getSections();
	   
	SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
	// There is always a section wrapper, but it might not contain a sectPr
	if (sectPr==null ) {
		sectPr = objectFactory.createSectPr();
		wordprocessingMLPackage.getMainDocumentPart().addObject(sectPr);
		sections.get(sections.size() - 1).setSectPr(sectPr);
	}

	HeaderReference headerReference = objectFactory.createHeaderReference();
	headerReference.setId(relationship.getId());
	headerReference.setType(HdrFtrRef.DEFAULT);
	sectPr.getEGHdrFtrReferences().add(headerReference);// add header or
	// footer references

}
 
开发者ID:asposemarketplace,项目名称:Aspose_Java_for_Docx4j,代码行数:23,代码来源:Docx4jHeaderCreate.java

示例9: initExport

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
@Override
protected void initExport() throws QueryException {
	try {
		factory = Context.getWmlObjectFactory();	
		for (int i=0; i<bean.getReportLayout().getColumnCount(); i++) {
			rowSpanForColumn.put(i, 1);
		}
		if (!bean.isSubreport()) {
			boolean landscape = (bean.getReportLayout().getOrientation() == LANDSCAPE);
			wordMLPackage = WordprocessingMLPackage.createPackage(PageSizePaper.A4, landscape);							
			setPageMargins();				
			addMetadata();						
		}
		table = createTable(PRINT_DOCUMENT);	
	} catch (InvalidFormatException e) {
           e.printStackTrace();
           throw new QueryException(e);
       }
	
}
 
开发者ID:nextreports,项目名称:nextreports-engine,代码行数:21,代码来源:DocxExporter.java

示例10: createFooterPart

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
 *  As in the previous example, this method creates a footer part and adds it to
 *  the main document and then returns the corresponding relationship.
 *
 *  @return
 *  @throws InvalidFormatException
 */
private static Relationship createFooterPart() throws InvalidFormatException {
    FooterPart footerPart = new FooterPart();
    footerPart.setPackage(wordMLPackage);
 
    footerPart.setJaxbElement(createFooterWithPageNr());
 
    return wordMLPackage.getMainDocumentPart().addTargetPart(footerPart);
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:16,代码来源:AddingPageNrToFooter.java

示例11: addCommentPart

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
 * Creates comment part to the docx if not exists or returns the existing
 * one
 * 
 * @return : the comment part of the docx file
 * @throws InvalidFormatException
 */
private org.docx4j.wml.Comments addCommentPart() throws InvalidFormatException {
	// Create and add a Comments Part
	org.docx4j.openpackaging.parts.WordprocessingML.CommentsPart commentsPart = new org.docx4j.openpackaging.parts.WordprocessingML.CommentsPart();
	this.mdp.addTargetPart(commentsPart);
	// Part must have minimal contents
	Comments comments = this.wmlObjectFactory.createComments();
	commentsPart.setJaxbElement(comments);
	return comments;
}
 
开发者ID:mjza,项目名称:MSThesis_Fidus_Docx_Converter,代码行数:17,代码来源:FidusToDocx.java

示例12: getNumberingPart

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
 * Extracts the numbering parts of the docx file
 * 
 * @return
 */
private org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart getNumberingPart() {
	org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart numbering = null;
	try {
		numbering = (org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart) this.wordMLPackage
				.getParts().get(new PartName("/word/numbering.xml"));
		if (numbering == null) {
			HashMap<org.docx4j.openpackaging.parts.PartName, org.docx4j.openpackaging.parts.Part> mp = this.wordMLPackage
					.getParts().getParts();
			Iterator<java.util.Map.Entry<org.docx4j.openpackaging.parts.PartName, org.docx4j.openpackaging.parts.Part>> it = mp
					.entrySet().iterator();
			while (it.hasNext()) {
				Map.Entry<org.docx4j.openpackaging.parts.PartName, org.docx4j.openpackaging.parts.Part> pair = (Map.Entry<org.docx4j.openpackaging.parts.PartName, org.docx4j.openpackaging.parts.Part>) it
						.next();
				if (pair.getValue() instanceof org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart) {
					numbering = (org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart) pair
							.getValue();
					break;
				}
				it.remove();
			}
		}
	} catch (InvalidFormatException e) {
		System.err.println("Couldn't load numbering part.");
	}
	return numbering;
}
 
开发者ID:mjza,项目名称:MSThesis_Fidus_Docx_Converter,代码行数:32,代码来源:DocxToFidus.java

示例13: addFooterWithPageNo

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
 * First we create the package and the factory. Then we create the footer.
 * Finally we add two pages with text to the document and save it.
 */

static void addFooterWithPageNo(WordprocessingMLPackage wordMLPackage) {
	ObjectFactory factory = Context.getWmlObjectFactory();
	Relationship relationship = null;
	try {
		relationship = createFooterPart(wordMLPackage, factory);
	} catch (InvalidFormatException e) {
		LOGGER.error("Creating the footer part failed with " + e.getMessage());
		LOGGER.debug(ExceptionUtils.getStackTrace(e));
	}
	createFooterReference(wordMLPackage, relationship, factory);
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:17,代码来源:AddPageNrToFooter.java

示例14: createFooterPart

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
 * As in the previous example, this method creates a footer part and adds it
 * to the main document and then returns the corresponding relationship.
 *
 * @return
 * @throws InvalidFormatException
 */
private static Relationship createFooterPart(WordprocessingMLPackage wordMLPackage, ObjectFactory factory) throws InvalidFormatException {
	FooterPart footerPart = new FooterPart();
	footerPart.setPackage(wordMLPackage);

	footerPart.setJaxbElement(createFooterWithPageNr(factory));

	return wordMLPackage.getMainDocumentPart().addTargetPart(footerPart);
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:16,代码来源:AddPageNrToFooter.java

示例15: createSlidePart

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
 * Create a slide and add it to the package
 * 
 * @param pp
 * @param layoutPart
 * @param i
 * @return the slide
 * @throws InvalidFormatException
 * @throws JAXBException
 */
private static SlidePart createSlidePart(MainPresentationPart pp, SlideLayoutPart layoutPart, int i) 
	throws InvalidFormatException, JAXBException {
	
	// Slide part
	SlidePart slidePart = new SlidePart(new PartName("/ppt/slides/slide" + i +".xml") );
	pp.addSlideIdListEntry(slidePart);

	slidePart.setJaxbElement( SlidePart.createSld() );
	
	// Slide layout part
	slidePart.addTargetPart(layoutPart);
	
	return slidePart;
}
 
开发者ID:asposemarketplace,项目名称:Aspose_Java_for_Docx4j,代码行数:25,代码来源:Pptx4jAutoShapes.java


注:本文中的org.docx4j.openpackaging.exceptions.InvalidFormatException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。