-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for document charts #128
Comments
@freb I'll have a look, allowing editing the spreadsheet shouldn't be too bad. If the charts work like they do in Excel, all you need to do is drop the numCache elements in your chart1.xml to cause the chart to be redrawn. I'll test and see if that works in Word as well. Since gooxml can evaluate formulas, it could always regenerate the numCache elements, but dropping them is easier and has worked so far. |
Hi! how do you add charts to word documents? |
@kendrickkesley Sorry, this still hasn't been done yet. |
Is there any plan to achieve this feature? |
Without unioffice support, it should be possible to get most of the way there. The approach would be to open up the docx file as a zip file and then find and edit the embedded spreadsheet using unioffice. The only real question is whether we have access to all of the For reference, here are my notes on the involved files and structures:
<wp:inline distB="0" distL="0" distR="0" distT="0" xmlns="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:xml="http://www.w3.org/XML/1998/namespace">
<wp:extent cx="5729161" cy="3787072"/>
<wp:effectExtent b="4445" l="0" r="5080" t="0"/>
<wp:docPr id="5" name="Chart 5"/>
<wp:cNvGraphicFramePr/>
<a:graphic>
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/chart">
<c:chart r:id="rId9" xmlns="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:s="http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes" xmlns:xml="http://www.w3.org/XML/1998/namespace"/>
</a:graphicData>
</a:graphic>
</wp:inline>
</w:drawing> It has <Relationship Id="rId9" Target="charts/chart1.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"/> This references file <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/package" Target="../embeddings/Microsoft_Excel_Worksheet.xlsx"/></Relationships> Which references Altering the spreadsheet and then setting I also considered updating the numCache directly without altering the embedded spreadsheet. This works OK, but as soon as you update fields in the document, like a table of contents, the numbers will revert. |
@freb What would you envision the API for this to be like? |
@gunnsth Sorry for the slow response. The API will really depend on exactly how much functionality you want to support around this. For my use case of taking an existing docx file that already has a chart as a placeholder and updating its values, it could be as simple as providing access to the embedded xlsx chart file and providing a mechanism for dropping the numCache. If, however, you want to support creating charts from scratch, this would obviously get a lot messier. When I was looking into this before, I didn't spend a lot of time reviewing the chart XML, but it looked involved enough that it wasn't something I wanted to tackle for my needs. |
Is there any support or planned support for adding charts or editing data associated with an existing chart?
I know that when a chart is created a spreadsheet gets embedded into the
word/embeddings
folder of the docx file. I also know that if you update this spreadsheet, the chart in the document doesn't get updated until you "edit data" from within word, unless you also change the data inword/charts/chart1.xml
.Being able to edit the embedded spreadsheet would probably be sufficient for my needs, but adding and editing charts would be fantastic. Any thoughts?
The text was updated successfully, but these errors were encountered: