poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 48042] Cannot save changes made to a chart
Date Wed, 28 Oct 2009 13:00:06 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=48042

Yegor Kozlov <yegor@dinom.ru> changed:

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

--- Comment #2 from Yegor Kozlov <yegor@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


Mime
View raw message