• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java InvalidFormatException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: replaceParams

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
private void replaceParams(org.docx4j.wml.Text t)
		throws InvalidFormatException {
	String text = t.getValue();
	if (text != null) {
		t.setSpace("preserve"); // needed?
		for (Entry<String, String> entry : dictionary.entrySet()) {
			String key = entry.getKey();
			String value = entry.getValue();
			int searchParam = 0;
			while (text.indexOf(key, searchParam) >= 0) {
				searchParam = text.indexOf(key, searchParam);
				System.out.println("Found " + key);
				int searchTerm = text.indexOf(key, searchParam);
				if (text.indexOf(value, searchParam) == searchTerm) {
					// likely an extended word, i.e. furor vs
					// furore
				} else if (text.indexOf(value, searchTerm - value.length()
						+ key.length()) == searchTerm) {
				} else {
					for (int i = 0; i < key.length(); i++) {
						int endString = searchParam + key.length() + 1;
						text = text.substring(0, searchParam).toString()
								+ value
								+ (endString < text.length() ? text
										.substring(
												searchParam + key.length()
														+ 1).toString()
										: "");
					}
				}
				searchParam = searchParam + value.length();
			}
		}
		System.out.println("New text: " + text);
		t.setValue(text);
	}
}
 
开发者ID:compassghost,项目名称:EnglishBridge,代码行数:38,代码来源:EnglishBridge.java


示例17: getCalculationChain

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
protected CTCalcChain getCalculationChain() {
    CTCalcChain calculationChain = null;
    try {
        CalcChain part = (CalcChain) result.getPackage().getParts().get(new PartName("/xl/calcChain.xml"));
        if (part != null) {
            calculationChain = part.getJaxbElement();
            calculationChain.getC().clear();
        }
    } catch (InvalidFormatException e) {
        //do nothing
    }
    return calculationChain;
}
 
开发者ID:cuba-platform,项目名称:yarg,代码行数:14,代码来源:XlsxFormatter.java


示例18: createHeaderReference

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
private 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 = factory.createSectPr();
		wordprocessingMLPackage.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:nextreports,项目名称:nextreports-engine,代码行数:16,代码来源:DocxExporter.java


示例19: createFooterReference

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
private 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 = factory.createSectPr();
		wordprocessingMLPackage.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:nextreports,项目名称:nextreports-engine,代码行数:16,代码来源:DocxExporter.java


示例20: createFooterPart

import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
 *  This method creates a footer part and set the package on it. Then we add some
 *  text and add the footer part to the package. Finally we return the
 *  corresponding relationship.
 *
 *  @return
 *  @throws InvalidFormatException
 */
private static Relationship createFooterPart() throws InvalidFormatException {
    FooterPart footerPart = new FooterPart();
    footerPart.setPackage(wordMLPackage);
    footerPart.setJaxbElement(WmlElementUtils.createFooter("Text"));
 
    return wordMLPackage.getMainDocumentPart().addTargetPart(footerPart);
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:16,代码来源:AddingAFooter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Streams类代码示例发布时间:2022-05-22
下一篇:
Java GrayPaintScale类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap