You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2009/10/23 05:20:45 UTC

DO NOT REPLY [Bug 48042] New: Cannot save changes made to a chart

https://issues.apache.org/bugzilla/show_bug.cgi?id=48042

           Summary: Cannot save changes made to a chart
           Product: POI
           Version: 3.5-FINAL
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: critical
          Priority: P2
         Component: XSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: nkalpana@gmail.com


Created an attachment (id=24408)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24408)
Original file containing a simple barchart

I  tried saving a change made to a chart of an Excel 2007 file
 for(POIXMLDocumentPart poixmlpartSheet : xssfSheet.getRelations())
                {

if(poixmlpartSheet.getPackageRelationship().getRelationshipType().equalsIgnoreCase("http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings")
== false)
                    {

if(poixmlpartSheet.getPackageRelationship().getRelationshipType().equalsIgnoreCase("http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing")
== true)
                        {
                            for(POIXMLDocumentPart poixmlpartDrawing :
poixmlpartSheet.getRelations())
                            {

if(poixmlpartDrawing.getPackageRelationship().getRelationshipType().equalsIgnoreCase("http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart")
== true)
                                {
                                    ChartSpaceDocument docChartSpace =
ChartSpaceDocument.Factory.parse(poixmlpartDrawing.getPackagePart().getInputStream());
                                    CTChartSpace xChartSpace =
docChartSpace.getChartSpace();
                                    CTChart xChart = xChartSpace.getChart();

                                    CTTitle xTitle = xChart.addNewTitle();

xTitle.addNewTx().addNewRich().addNewP().addNewR().setT("new title");
                                    xChart.setTitle(xTitle);
                                    XmlOptions oOptions = new XmlOptions();

docChartSpace.save(poixmlpartDrawing.getPackagePart().getOutputStream(),
oOptions);
                                }
                            }
                        }
                    }

                }


The original file "Barchart.xlsx" did not have a title. 
Is there a specific way to save changes to a chart?

Regards,
nk

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 48042] Cannot save changes made to a chart

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48042

--- Comment #3 from Kalpana <nk...@gmail.com> 2009-10-28 07:17:55 UTC ---
Thanks Yegor,

I figured it out myself over the weekend. Reading up on the mandatory nodes
required for chart title, helped me.

I forgot to update this message, and close it.

Sorry for the unnecessary thread.

Regards,
Kalpana

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 48042] Cannot save changes made to a chart

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48042

Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

--- Comment #2 from Yegor Kozlov <ye...@dinom.ru> 2009-10-28 06:00:03 UTC ---
There are two errors:

(1) PackagePart's output stream must be closed. 

(2) bodyPr is a required element in CT_TextBody, see 5.7.2.157 of the OOXML
spec.

The correct code to set chart title is as follows:

  ChartSpaceDocument docChartSpace =
         
ChartSpaceDocument.Factory.parse(poixmlpartDrawing.getPackagePart().getInputStream());
  CTChartSpace xChartSpace =
          docChartSpace.getChartSpace();
  CTChart xChart = xChartSpace.getChart();

  CTTitle xTitle = xChart.addNewTitle();

  CTTextBody ctBody = xTitle.addNewTx().addNewRich();
  ctBody.addNewBodyPr(); //required
  ctBody.addNewP().addNewR().setT("new title");
  xChart.setTitle(xTitle);
  XmlOptions oOptions = new XmlOptions();

  PackagePart part = poixmlpartDrawing.getPackagePart();
  OutputStream out = part.getOutputStream();
  docChartSpace.save(out, oOptions);
  out.close(); //must close


Yegor

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 48042] Cannot save changes made to a chart

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48042

--- Comment #1 from Kalpana <nk...@gmail.com> 2009-10-22 20:22:37 UTC ---
Created an attachment (id=24409)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24409)
The file created after Chartspace doc changes. Excel throws "unreadable
content" error when this is opened, and removes the drawing1.xml part

The file created after Chartspace doc changes. Excel throws "unreadable
content" error when this is opened, and removes the drawing1.xml part

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org