We're pleased to announce the release of Spire.Doc for Java 14.4.9. This version supports saving charts as templates, and provides the XValues and YValues properties to retrieve data values from charts. Additionally, it supports getting and setting the position of chart data labels. Meanwhile, some issues that occurred when converting Word to PDF, HTML to Word, and Markdown to Word have also been successfully fixed. More details are listed below.
Here is a list of changes made in this release
| Category | ID | Description |
| New Feature | SPIREDOC-10293 | Supports saving charts as templates.
Document doc = new Document();
doc.loadFromFile(inputFile);
int count = 1;
for (Section sec : (Iterable) doc.getSections()) {
for (Paragraph paragraph : (Iterable) sec.getParagraphs()) {
for (int i = 0; i < paragraph.getChildObjects().getCount(); i++) {
DocumentObject obj = paragraph.getChildObjects().get(i);
if (obj instanceof ShapeObject) {
ShapeObject shape = (ShapeObject) obj;
Chart chart = shape.getChart();
String fileName = outputFile + count + ".crtx";
chart.saveAsTemplate(fileName);
count++;
}
}
}
}
|
| New Feature | SPIREDOC-10828 | Adds the XValues property to retrieve data XValues on the chart's X-axis, and the YValues property to retrieve data values on the Y-axis for a specified series.
Document doc = new Document();
doc.loadFromFile(inputFile);
StringBuilder sb = new StringBuilder();
int pageNumber = 1;
for (Section sec : (Iterable) doc.getSections()) {
for (Paragraph paragraph : (Iterable) sec.getParagraphs()) {
for (int i = 0; i < paragraph.getChildObjects().getCount(); i++) {
DocumentObject obj = paragraph.getChildObjects().get(i);
if (obj instanceof ShapeObject) {
ShapeObject shape = (ShapeObject) obj;
Chart chart = shape.getChart();
sb.append("\r\n\r\nPage " + pageNumber + ":\r\n" + "All X-axis data: ");
for(int x = 0; x < chart.getXValues().getCount(); x++){
// Print all X-axis data values
ChartValue xVal = chart.getXValues().get(x);
sb.append(xVal.getStringValue() + " ");
}
ChartSeries series = chart.getSeries().get(0);
sb.append("\r\nY-axis data: ");
// Print all Y-axis data values of the first series
for(ChartValue yVal : (Iterable<ChartValue>)series.getYValues()){
sb.append(yVal.getValue() + " ");
}
}
}
}
pageNumber++;
}
|
| New Feature | SPIREDOC-11457 | Supports getting and setting the position of chart data labels.
Document doc = new Document();
for (ChartDataLabelPosition position : ChartDataLabelPosition.values()) {
Section section = doc.addSection();
section.addParagraph().appendText(position.name());
Paragraph newPara = section.addParagraph();
ShapeObject shape = newPara.appendChart(ChartType.Pie, 500, 300);
Chart chart = shape.getChart();
chart.getSeries().get(0).hasDataLabels(true);
chart.getSeries().get(0).getDataLabels().setShowCategoryName(true);
chart.getSeries().get(0).getDataLabels().setShowValue(true);
chart.getSeries().get(0).getDataLabels().setPosition(position);
ShapeObject shape2 = newPara.appendChart(ChartType.Bubble, 500, 300);
Chart chart2 = shape2.getChart();
chart2.getSeries().get(0).hasDataLabels(true);
chart2.getSeries().get(0).getDataLabels().setShowCategoryName(true);
chart2.getSeries().get(0).getDataLabels().setShowValue(true);
chart2.getSeries().get(0).getDataLabels().setPosition(position);
}
doc.saveToFile(outputFile, FileFormat.Docx);
|
| Bug Fix | SPIREDOC-11796 | Fixes the issue where some image sizes were not automatically scaled when converting HTML to Word. |
| Bug Fix | SPIREDOC-11885 | Fixes the "NullPointerException" exception that occurred when converting Word to PDF. |
| Bug Fix | SPIREDOC-11770 | Fixes the "There are too many styles in the document" exception that occurred when converting Word to PDF. |
| Bug Fix | SPIREDOC-11826 | Fixes the issue where tables and images were lost when converting Markdown to Word. |
| Bug Fix | SPIREDOC-11836 | Fixes the issue where field updating failed when converting Word to PDF. |
| Bug Fix | SPIREDOC-11868 | Fixes the "NullPointerException" exception that occurred when populating control content. |
| Bug Fix | SPIREDOC-11876 | Fixes the "NullPointerException" exception that occurred when reading document data in a multi-threaded environment. |
Click the link below to download Spire.Doc for Java 14.4.9: