Page 1 of 1

pathnames embedded excel files

PostPosted: Sun Jun 11, 2023 12:02 am
by HansR
When looking for the filename of an excelfile, containing the data of a chart, via
Code: Select all
List<Relationship> rsp = chart.getRelationshipsPart().getRelationships().getRelationship();
      for (Relationship rs : rsp) {
         if (rs.getType().equals(Namespaces.EMBEDDED_PKG)) {
               excelFilename = rs.getTarget();
               break;
            }
         }


the code returns "../embeddings/Microsoft_Excel_Worksheet1.xlsx" as pathname.

However, the partname needed to open this file needs to be "/word/embeddings/Microsoft_Excel_Worksheet1.xlsx"

Can I safely replace the 2 dots by "/word" ?

Re: pathnames embedded excel files

PostPosted: Tue Jun 13, 2023 10:44 pm
by jason
Hi Hans

A target of the form Target="../embeddings/Microsoft_Excel_Worksheet.xlsx" is what Word writes (tested Word version 2305 Build 16501.20196), which is likely why you are seeing that.

When you say the partname needed to open this file needs to be "/word/embeddings/Microsoft_Excel_Worksheet1.xlsx", do you mean opening it from docx4j, or in some other context?

cheers .. Jason