Graph Apperance

Hi


I am currently testing out the graphing functionality of Aspose Cells for Java.

Is there any way to create graphs that appear as they would if created natively in Excel 2010 which just look more polished than the ones created from Aspose that look more “dated”.

I have attached a example xls to demonstrate.

Kind Regards

Iain

Hi,


Well, your desired chart is MS Excel 2007/2010 (XLSX format type) oriented but your Excel file is XLS (Excel 97-2003), so when you save/create in XLS format using Aspose.Cells for Java API, your chart looks in prior fashion. If you need to create Excel 2007/2010 oriented chart, please save your Excel file to Excel 2007/2010 e.g XLSX format instead of XLS, it would work fine. Here is my sample code that works and the generated chart looks same as your desired chart. I used the data range for chart in your template file, see the sample code below:

Sample code:


Workbook book = new Workbook();
book.open(“MyBook1.xls”);
Worksheet sheet = book.getWorksheets().getSheet(0);
Cells cells = sheet.getCells();
Chart chart = sheet.getCharts().addChart(ChartType.BAR_3D_STACKED, 30, 2, 50, 10);
chart.getNSeries().add(“A1:B3”, true);
chart.getCategoryAxis().getAxisLine().setVisible(false);
chart.getCategoryAxis().setVisible(true);
book.save(“BarStacked3d.xlsx”, FileFormatType.XLSX);


Thank you.


Excellent many thanks for your quick response.


I take it I am then able to copy this chart and embed into a Word document using Aspose.Word, could you confirm that is correct, if it does I think the purchase decision will have been made!

Hi,


Well, yes, you may also take the image of the chart using Chart to Image feature (that Aspose.Cells for .NET provides) and insert the image into word document using Aspose.Words product.

Thank you.

Are you also able to do this with the java version of the software?



Are the 2 versions very similar or does the .net version offer a greater amount of features?

Hi,


Sorry for the confusion. I should have given you the Aspose.Cells for Java documentation topic instead.

Well, you may also take the image of the chart using chart to image feature (that Aspose.Cells for Java provides) and insert the image into word document using Aspose.Words for Java product.

Thank you.

Brilliant thanks,


The problem I have now is when I save the image from the workbook if saves the image as the “old style” chart when the chart in the excel workbook is XLSX format.


workbook.open(“MyBook.xlsx”); // This is displaying new style xlsx chart
ImageOptions imgOpts = new ImageOptions();
imgOpts.setImageFormat(ImageFormat.PNG); // Have tried all the options
imgOpts.setFashion(FileFormatType.UNKNOWN); // API said unknown would use format of file
chart.toImage(“myChart.png”, imgOpts);





Hi,


I have tested the issue and found it. May be it is still a limitation that we cannot take the image of Excel 2007 XLSX oriented by Aspose.Cells for Java.

Sample code:

Workbook book = new Workbook();
book.open(“MyBook.xls”);
Worksheet sheet = book.getWorksheets().getSheet(0);
Cells cells = sheet.getCells();
Chart chart = sheet.getCharts().addChart(ChartType.BAR_3D_STACKED, 30, 2, 50, 10);
chart.getNSeries().add(“A1:B3”, true);

chart.getCategoryAxis().getAxisLine().setVisible(false);
chart.getCategoryAxis().setVisible(true);
ImageOptions imgOpts = new ImageOptions();
imgOpts.setImageFormat(ImageFormat.PNG);
imgOpts.setFashion(FileFormatType.XLSX);
//…
//…


chart.toImage(“myChart.png”, imgOpts);

I have logged a ticket for the issue with an id: CELLSJAVA-29805. We will look into it and get back to you soon.

thank you.

Ok, that is a shame.


So is there a way that the Excel native chart can be embeded into a word document rather than converting it to am image, to be honest that would probably be better than an image anyway.

Cheers

Hi,


We will figure the issue soon.

Regarding embedding Excel file (with charts) in a word document, kindly ask your query to Aspose.Words team, you may post a query in Aspose.Words forum, they will help you soon.

Thank you.

Hi,

We found the issue of rendering the newly created chart to image. After initial testing, we found the chart serieses were not rendered on the image. It is the issue we need to fix.

However, from the your post and code at

https://forum.aspose.com/t/124293

We think maybe you were talking about the appearance of the generated image for existing chart in template file. If your “MyBook.xlsx” was just re-saved from “MyBook.xls”, the first chart will be surely drawn as “old style” because its properties had been explicitly customed as what should be in old style in the xlsx file when re-saving it by ms excel. And even opened in ms excel, the first chart should be shown as “old style” too. So we will surely render it according to its explicitly defined properties and the generated image will look like “old style”.

Hi,


I am not sure exactly what you mean but even if I open an XLSX document with the “new style” chart when I generate an image of the the chart within it using toImage() it still creates a PNG in the “old style”.

Workbook book = new Workbook();
book.open(“MyBook.xlsx”);
Worksheet sheet = book.getWorksheets().getSheet(0);
Chart chart = sheet.getCharts().getChart(0);
ImageOptions imgOpts = new ImageOptions();
imgOpts.setImageFormat(ImageFormat.PNG);
chart.toImage(“myChart.png”, imgOpts);

I hope this answers your question.

Cheers

Iain


Hi,

We have found issues with chart series. Once, we will fix them, we will update you here.

Hi,

Please download the latest version and read the release notes: Aspose.Cells for Java v7.0.0

Code:

workbook.setFileFormat(FileFormatType.XLSX);

Chart chart = charts.get(charts.add(…));

ImageOrPrintOptions opts…

chart.toImage(…);