Hi,
I have a excel file with multiple tabs in it and each tab has only one graph in it.
I have to (for each graph in the various tabs):
a) set the font for the categoryaxis, valueAxis,legend to size 8.
b) resize the chart horizontally so that it fits within the print area of a US letter size paper (8.5 by 11 inches)
I was able to get point a) done. Point b) does not seem to get done.
Source code:
/******************************************************************************************************/
public static void main(String[] args)
{
Workbook workbook = null;
try {
workbook = new Workbook(“C:\Aspose_Test_Data.xlsx”);
}
catch (Exception ex) {
System.out.println(“Error message is :”+ ex);
}
Worksheet _worksheet = workbook.getWorksheets().get(0);
Chart chart = _worksheet.getCharts().get(0);
chart.getCategoryAxis().getTickLabels().getFont().setSize(8);
chart.getValueAxis().getTickLabels().getFont().setSize(8);
chart.getLegend().getFont().setSize(8);
System.out.println(“the Height of the chart is:” + chart.getChartArea().getHeight());
System.out.println(“the Width of the chart is:” + chart.getChartArea().getWidth());
chart.getChartArea().setWidth(3300);
System.out.println(“the set width of the chart now is:” + _worksheet.getCharts().get(0).getChartArea().getWidth());
try {
workbook.save(“C:\Aspose_Test_Data_new.xlsx”, FileFormatType.XLSX);
} catch (Exception ex) {
System.out.println(“Error message is :”+ ex);
}
/************************************************/
chart.getChartArea().getHeight() prints 0 and chart.getChartArea().getWidth() also prints 0.
There is no change in the size of the graph (even if I set it to different values). anything extra that should be done here?
Sample file attached too here.