We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Chart to image problem

I am converting a chart in excel to image but the chart has many values in x-axis and values are overlapping over each other. Please give me solution to this problem. I am attaching chart image.image.png (27.0 KB)

@Archie000

Thanks for considering Aspose APIs.

Please provide us your Excel file containing your Chart. We will convert it to image and replicate the issue at our end. In case of some bug, we will fix it in our next releases. Thanks for your cooperation in this regard and have a good day.

Please find the excel file attached. Weekly.zip (92.7 KB)

@Archie000,

Please try our latest version/fix: Aspose.Cells for .NET 18.2.

I have tested using your template file to convert to PNG image format, it works fine and I do not see x-axis values/labels overlapping.
e.g
Sample code:

Workbook workbook = new Workbook("e:\\test2\\Weekly.xlsx");
            Chart chart = workbook.Worksheets["IUPSPortWise_Chart"].Charts[0];
            System.Drawing.Bitmap img = chart.ToImage();
            img.Save("e:\\test2\\out1chartimage.png");

out1chartimage.png (7.8 KB)

Please also check the following article:

Can you please provide the java version of it?
There is no option to get it in bitmap in java

please try the chart to image using Java as I am still not able to get correct images for these chart.

@Archie000,

Please try our latest (Java) version/fix: this Aspose.Cells for Java 18.2.

I have tested using v18.2, it works fine and the output image of the chart is fine tuned:
e.g
Sample code:

Workbook workbook = new Workbook("e:\\test2\\Weekly.xlsx");
            Chart chart = workbook.getWorksheets().get("IUPSPortWise_Chart").getCharts().get(0);
            chart.toImage("e:\\test2\\out1chartimage.png");

Please also check the following document/blog for your reference:

Hi,

I am using the latest aspose.cell 18.2. This is the image I am getting for IUPS portwise. IUPS Port Wise.png (5.1 KB)
Can you share the image you are getting?Please try with the excel I am sharing now.H- Weekly.zip (555.5 KB)

@Archie000,

Please find attached the output image I am getting using Aspose.Cells for Java v18.2 with your original file.
out1chartimage.png (5.4 KB)

Hi,

I am doing chart.refreshPivotData() before chart.toImage() since I have to update the pivot chart. Could this be the reason for getting incorrect image?

Hi,
If I take chart image from excel without first opening and manually saving it(Ctrl+S), then I get the incorrect chart image. When I try the code after opening and saving the saving the file, then images obtained are correct. Can you provide me any solution for this?

@Archie000

We will look into this issue and update you asap.

@Archie000,

Please provide us sample console (Java) code (runnable) to reproduce the issue on our end, we will check it soon.

Hi,

I am attaching the sample code and template files.Sample.zip (495.4 KB)

@Archie000

Thanks for considering Aspose APIs.

Please simplify your code and provide us your runnable code. At the moment, your code is not runnable and it gives compile time errors as shown in screenshot.

Hi,

You need to import Apache POI libraries for them. But for your ease, I am attaching the sample code without them.Sample.zip (493.0 KB)

@Archie000

The code is still not runnable. There are errors in readFiles() method. Please see the attached screenshot.

errors.png (107.7 KB)

Sample1.zip (3.5 KB)
Hi Sorry about the wrong file. Please find attached the runnable code.

@Archie000

We are afraid, your code is still not acceptable. It is runnable but after much efforts. Please see the console output generated by your code. Your code is quite complex. Please work on your code and remove all the unnecessary stuff relating to business logic and provide us the simplified code that replicates the problem with few lines.

Console Output

java.lang.NullPointerException
	at Sample.readFiles(Sample.java:420)
	at Sample.doProcess(Sample.java:77)
	at Sample.main(Sample.java:54)
NasirssssF:/Download/op/
Erlang-Payload-Chart :: PAYLOAD_TOTAL_3G_MBYTE
Erlang-Payload-Chart :: ERLANG_3G_SPEECH
3G KPIs-Chart :: CSSR_SPEECH
3G KPIs-Chart :: CSSR_PS_ALL
3G KPIs-Chart :: DCR_SPEECH
3G KPIs-Chart :: DCR_PS_ALL
3G KPIs-Chart :: IRATHO_SUC_RATE
3G KPIs-Chart :: Number of Cells
3G KPIs-Chart :: PS RAB Success Rate
ACTIVE_PDP_Chart :: ACTIVE_PDF
VLR_Subs_3G_2G_Chart :: VLR_RATIO
Pivot_Deletion :: Paging_deletion
Pivot_Intensity :: Paging_Intensity
IUB_complete_Chart :: IUB All
IUPS_complete_Chart :: IUPS All
IUPSPortWise_Chart :: IUPS Port Wise
IUBPortWise_Chart :: IUB Port Wise
Huawei_LTE_Charts :: RRC_EST_SR
Huawei_LTE_Charts :: ERAB_EST_SUC_INITIAL
Huawei_LTE_Charts :: ERAB_EST_SR_ADDED
Huawei_LTE_Charts :: ERAB_DROP_RATE
Huawei_LTE_Charts :: HO_SUC_RATE_INTRAF_O
Huawei_LTE_Charts :: PDCP_DATA_VOL_DL
Huawei_LTE_Charts :: PDCP_DATA_VOL_UL
Huawei_LTE_Charts :: Count of cells
Huawei_LTE_Charts :: Paging Deletion Rate
Huawei_LTE_2_Charts :: PDCP_DATA_VOL_DL
Huawei_LTE_2_Charts :: PDCP_DATA_VOL_UL
Huawei_LTE_2_Charts :: THRPUT_UE_DL
Huawei_LTE_2_Charts :: THRPUT_UE_UL
Huawei_2G_Charts :: CSSR
Huawei_2G_Charts :: DCR
Huawei_2G_Charts :: HOSR
Huawei_2G_Charts :: TCH_AVAILABILITY
Huawei_2G_Charts :: Number_of_Cells
Huawei_2G_Charts :: PAGING_DELETION
Huawei_2G_Charts :: PCU_Congestion
GI_Throughput :: GI_UL_PEAK_THRU
GI_Throughput :: GI_DL_PEAK_THRU
Huawei_Payload_Erlang_Charts :: PAYLOAD_LLC_TOTAL_KBYTE
Huawei_Payload_Erlang_Charts :: ERLANG
IRATHO_PREP_Chart :: IRATHO_PREP
258242
Process Complete
java.lang.ArrayIndexOutOfBoundsException: 0
	at Sample.writeToPPT(Sample.java:148)
	at Sample.doProcess(Sample.java:82)
	at Sample.main(Sample.java:54)

Screenshot

Hi Shakeel,

Thanks for your support. Here I am attaching the input files and simplified code. Please check the output chart images, I want the date format to be dd-mmm-yyyy in chart image but pivot is not refreshing the dates correctly and also image distortion in some images. I am using aspose-java 18.2.
I.zip (289.2 KB)