简体   繁体   English

错误:由以下原因引起:java.lang.IllegalArgumentException:关系null并非从此部分开始/ppt/slides/slide3.xml

[英]ERROR : Caused by: java.lang.IllegalArgumentException: Relationship null doesn't start with this part /ppt/slides/slide3.xml

I'm working with apache poi xslf to export ppt file. 我正在与Apache Poi xslf一起导出ppt文件。 First, I have a template set with 3 slides : title slide, summary slide, and third slide 首先,我有一个包含3张幻灯片的模板集:标题幻灯片,摘要幻灯片和第三张幻灯片

I duplicate the 3rd slide (i have it as a template) in order to copy many data/graphics as I have in database. 我复制了第三张幻灯片(我将其作为模板),以便像在数据库中一样复制许多数据/图形。

So in order to do that : 因此,为了做到这一点:

XMLSlideShow slideShow = new XMLSlideShow(dlfile.getContentStream());
XSLFSlide[] slides = slideShow.getSlides();
XSLFSlide createdSlide = slideShow.createSlide(slides[2].getSlideLayout());
//get content from slide to createdslide
createdSlide.importContent(slides[2]); 
//... add data to created slide

I have an error at line : createdSlide.importContent(slides[2]); 我在行上出错: createdSlide.importContent(slides[2]);

Caused by: java.lang.IllegalArgumentException: Relationship null doesn't start with this part /ppt/slides/slide3.xml
    at org.apache.poi.openxml4j.opc.PackagePart.getRelatedPart(PackagePart.java:468)
    at org.apache.poi.xslf.usermodel.XSLFSheet.importBlip(XSLFSheet.java:521)
    at org.apache.poi.xslf.usermodel.XSLFSlide.importContent(XSLFSlide.java:235)

PS : this code works just fine with another tempalte. PS:此代码可以与另一个模板一起使用。 I need to use different templates based on user selection. 我需要根据用户选择使用不同的模板。 (templates are stored in db as i'm using liferay). (当我使用liferay时,模板存储在db中)。

I've searched for hours, but in vain! 我搜索了几个小时,但徒劳! I don't even understand what the error means. 我什至不明白错误的含义。

Any links/help would appreciated. 任何链接/帮助将不胜感激。

The error comes from org.apache.poi.openxml4j.opc.PackagePart.getRelatedPart code line 468: 该错误来自org.apache.poi.openxml4j.opc.PackagePart.getRelatedPart代码行468:

throw new IllegalArgumentException("Relationship " + rel + " doesn't start with this part " + _partName); .

The error states that rel is null. 该错误指出rel为空。 So org.apache.poi.xslf.usermodel.XSLFSheet.importBlip in code line 521: 因此在代码行521中的org.apache.poi.xslf.usermodel.XSLFSheet.importBlip

blipPart = packagePart.getRelatedPart(blipRel);

had handed over blipRel as null. 已将blipRel移交为null。 So org.apache.poi.xslf.usermodel.XSLFSlide.importContent in code line 235: 因此,在代码行235中的org.apache.poi.xslf.usermodel.XSLFSlide.importContent

String relId = importBlip(blipId, src.getPackagePart());

had handed over blipId as null. 已将blipId移交为null。

This is pretty clear if one of the pictures in your template in Slide 3 is not an embedded picture but a linked picture. 如果幻灯片3中模板中的图片之一不是嵌入式图片而是链接图片,则这很清楚。 The code: 编码:

@Override
public XSLFSlide importContent(XSLFSheet src){
    super.importContent(src);

    XSLFBackground bgShape = getBackground();
    if(bgShape != null) {
        CTBackground bg = (CTBackground)bgShape.getXmlObject();
        if(bg.isSetBgPr() && bg.getBgPr().isSetBlipFill()){
            CTBlip blip = bg.getBgPr().getBlipFill().getBlip();
            String blipId = blip.getEmbed();

            String relId = importBlip(blipId, src.getPackagePart());
            blip.setEmbed(relId);
        }
    }
    return this;
}

consideres only embedded blip data. 仅考虑嵌入的blip数据。

From your code lines I can see that you are using apache poi version 3.9. 从您的代码行中,我可以看到您正在使用apache poi 3.9版。 But as far as I see in current versions this had not changed until now. 但是据我目前的版本来看,这直到现在都没有改变。 Only embedded bilp data will be considered. 仅考虑嵌入的Bilp数据。

So have a look at your template and make sure that all pictures are embedded and not linked. 因此,请查看您的模板,并确保所有图片均已嵌入且未链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 引起:java.lang.illegalArgumentException - Caused by: java.lang.illegalArgumentException 由 java.lang.IllegalArgumentException 引起:MediaButtonReceiver 组件可能不为空 - Caused by java.lang.IllegalArgumentException: MediaButtonReceiver component may not be null java.lang.IllegalArgumentException:im == null! 错误 - java.lang.IllegalArgumentException: im == null! error 原因:java.lang.IllegalArgumentException:主机名不能为null - Caused by: java.lang.IllegalArgumentException: Host name may not be null Servlet:原因:java.lang.IllegalArgumentException:无法转换参数:null - servlet: Caused by: java.lang.IllegalArgumentException: Can't convert argument: null 引发的Java weblogic错误:java.lang.IllegalArgumentException - Java weblogic error with Caused by: java.lang.IllegalArgumentException 原因:java.lang.IllegalArgumentException: error at::0 切入点中的正式未绑定 - Caused by: java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut 引起:java.lang.IllegalArgumentException::: 0处的错误找不到引用的切入点 - Caused by: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut 计时器计划由:java.lang.IllegalArgumentException - Timer schedule Caused by: java.lang.IllegalArgumentException 引起:java.lang.IllegalArgumentException:不是实体: - Caused by: java.lang.IllegalArgumentException: Not an entity:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM