Excel to PDF conversion - Render data labels without overlapping on Donuts charts using Aspose.Cells for Java

When we generate the pdf file with excel template data label of donuts chart are overlapped. However charts label are fine(not overlapped) in template file. Sample template file, screen-shot of pdf file and set of code we used are as follows.
Code:

    FileInputStream io1=new FileInputStream(new File("utilization_dashboard_ea_withData1.xlsx"));
	Workbook workbook1 = new Workbook(io1);
	workbook1.save("utilizationDashboard_ea_templateFile.xlsx");

        FileInputStream io=new FileInputStream(new File("utilizationDashboard_ea_templateFile.xlsx"));
	Workbook workbook = new Workbook(io);
	workbook.calculateFormula();
	
	for (int m = 0; m < workbook.getWorksheets().getCount(); m++) {
		workbook.getWorksheets().get(m).getShapes().updateSelectedValue();
	}

	for (int j = 0; j < workbook.getWorksheets().getCount(); j++) {
		def sheetName=workbook.getWorksheets().get(j).getName();
		if ((sheetName.startsWith("_") || sheetName.contains("staging") ||sheetName.contains("Staging")) {
			workbook.getWorksheets().get(j).setVisible(false);
		}
	}
	
	workbook.save("PDF_Result_file.pdf");

PDF File screen-shot:
pdf_screenShot.png (75.2 KB)
Sample template with raw data:
sample_template_file.zip (57.8 KB)

@brpokharel,

Which version of the product you are using? I tested your scenario/ case using your sample code and template file and it works Ok and as expected. I am using our latest version/fix: Aspose.Cells for Java v19.12.4 (attached). Please try our latest version, it will work fine.

Let us know if you still find the issue with v19.12.x.
aspose-cells-19.12.4-java.zip (6.8 MB)

We are using aspose-cells-19.11 and aspose-pdf-19.5 aspose version.

Thanks for quick response and providing latest jar of aspose-cells. We will check with this and update you.

@brpokharel,

Sure, take your time to evaluate the latest version/fix. In the event of any issue or queries, feel free to write us back, we will happy to assist you soon.

@ Amjad_Sahi

We are still getting same issue even if we used the latest aspose-cell jar file you provided. For reference screen-shot of pdf file is attached. Please look into this here the data-labels (14,3,7) of donuts charts are overlapped but you can see it is fine in template file (display sheet / ‘Utilization Dashboard’) which I have already attached .

labelOverlapped_pdf_screenShot.png (17.8 KB)

@brpokharel,

Thanks for the screenshot.

I tested the following sample code with your template file and it work. Please find attached the output file for your reference. Here is sample code I am using:
e.g
Sample code:

Workbook workbook = new Workbook("e:\\test2\\utilization_dashboard_ea_withData1.xlsx");
		workbook.calculateFormula();
		
		for (int m = 0; m < workbook.getWorksheets().getCount(); m++) {
			workbook.getWorksheets().get(m).getShapes().updateSelectedValue();
		}

		workbook.save("f:\\files\\PDF_Result_file1.pdf"); 

It might be some missiing fonts issue on your end. Please make sure that the following fonts (which are used in the workbook) should be installed on your enviroment:
LucidaSans, Arial, Calibri, Tahoma, etc

Also, you got toset the fonts folder for rendering in your code at the start of the program:

If you still find the issue, kindly do share your output PDF file, we will check it soon.
PDF_Result_file1.pdf (159.3 KB)

@ Amjad_Sahi

Issue still exist. Here our main concern is, pdf file is not generate as its respective template we have.

In template (excel file) data label are not overlapped on donuts chart with name ’ Admissions by Type ’ . That means,when we open up the excel template in MS-Office (I used MS-Office 2016) we found there is no data label overlapping issue in chart. For reference I have attached the screen-shot view of template when open up in MS-Office excel and I have marked with red arrow.
templateView_screen_shot.png (87.0 KB)

When we used the same template for generating the PDF, issue encountered as chart labels are overlapping. We can say chart in pdf was not prepared as it is in template we have. For your reference I have attached a complete pdf file which looks similar as you have provided. But the issue is existed in pdf file you have provided(attached). You can compare the chart with name 'Admissions by Type ’ in template screen-shot view and pdf you have provided. I hope after comparing this you will notice the actual issue.

pdf_result_sampleFiile.pdf (56.4 KB)

Any updates on this?

@brpokharel,

Thanks for providing further details, screenshot and output PDF.

After further evaluation, I am able to observe the issue as you mentioned by converting your template file to PDF file format. I found some data labels in your mentioned Donut chart “Admissions by Type” are overlapped.
e.g
Sample code:

Workbook workbook = new Workbook("e:\\test2\\utilization_dashboard_ea_withData1.xlsx");
        workbook.calculateFormula();

        for (int m = 0; m < workbook.getWorksheets().getCount(); m++) {
            workbook.getWorksheets().get(m).getShapes().updateSelectedValue();
        }

        workbook.save("f:\\files\\PDF_Result_file1.pdf");  

Please also find attached the screenshot to highlight your mentioned issue. I have logged a ticket with an id “CELLSJAVA-43091” for your issue. We will look into it to figure it out soon.

Once we have an update on it, we will let you know.
sc_shot1.png (132.3 KB)

@ Amjad_Sahi

Thanks for update. We are looking forward to fix this issue in near future.

@brpokharel,

Sure, we will try to resolve the issue soon.

Once we have any new information available, we will update you.

@brpokharel,

This is to inform you that we have fixed your issue (logged earlier as “CELLSJAVA-43091”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@brpokharel,

Please try our latest version/fix: Aspose.Cells for Java v20.1.1:
aspose-cells-20.1.1-java.zip (6.8 MB)

Your issue should be fixed in it.

Let us know your feedback.

@ Amjad_Sahi

Thanks for this latest version of aspose-cells. We will check this jar file and let you know whatever the comes up.

@brpokharel,

Sure, please take your time to evaluate the fix, hopefully it will pass your test cases. We did test using your template file and sample code and it works Ok.

@ Amjad_Sahi

I have tested with above attached jar file but our issue/case still does not resolved with above jar file. As you know I have already provided the details on this. Please look into this from your end.

@brpokharel

Please make sure that you are using the fixed version. For confirmation, you may print the version number at the start of your code:
e.g
Sample code:

.........
System.out.println(CellsHelper.getVersion()); 

Also, see the attached screenshot of the PDF page (after using my sample code) which does not show the issue.
sc_shot1.png (92.2 KB)

If you still find the issue, kindly do paste your sample code with template file and output PDF file, we will check it soon.

@ Amjad_Sahi

We are still getting issue. More details are as follows.
Sample Code:

 try {
            System.out.println("Aspose cell version=====");
            System.out.println(CellsHelper.getVersion());
            FileInputStream io1=new FileInputStream(new File("utilization_dashboard_Template_output.xlsx"));
            Workbook workbook1 = new Workbook(io1);
            workbook1.save("temporary_saved_templateFile.xlsx");

            FileInputStream io = new FileInputStream(new File("temporary_saved_templateFile.xlsx"));
            Workbook workbook = new Workbook(io);
            workbook.calculateFormula();

            for (int m = 0; m < workbook.getWorksheets().getCount(); m++) {
                workbook.getWorksheets().get(m).getShapes().updateSelectedValue();
            }

            for (int j = 0; j < workbook.getWorksheets().getCount(); j++) {
                def sheetName = workbook.getWorksheets().get(j).getName();
                if ((sheetName.startsWith("_") || sheetName.contains("staging") || sheetName.contains("Staging"))) {
                    workbook.getWorksheets().get(j).setVisible(false);
                }
            }
            workbook.save("PDF_Result_file.pdf");
        } catch (Exception e) {
            e.printStackTrace();
        }

Logs with aspose-cell version printed.

8:02:01 PM: Executing task 'LogoTest.main()'...

:compileJava UP-TO-DATE
Picked up _JAVA_OPTIONS: -Xms600m -Xmx1024m
:compileGroovy
:processResources UP-TO-DATE
:classes
Picked up _JAVA_OPTIONS: -Xms600m -Xmx1024m
:LogoTest.main()
Aspose cell version=====
20.1.7

BUILD SUCCESSFUL

Total time: 34.182 secs
8:02:37 PM: Task execution finished 'LogoTest.main()'.

Template/excel file and pdf file.
PDF_Result_file.pdf (83.3 KB)
utilization_dashboard_Template_output.zip (57.8 KB)

Please look into this from your end.

@brpokharel,

Thanks for the template file, sample code and output PDF.

You are right, the issue is still there. I tested using your sample code with your attached file and found the issue. However, if I open your attached file into MS Excel 2007 I can see those labels are overlapped too. But when I use MS Excel 2013, data labels are not overlapped. So, it’s a kind of different Ms Excel versions behaviors. It looks like Aspose.Cells is following MS Excel 2007 in this case. Anyways, I have reopened your issue and we will look into it soon.

@ Amjad_Sahi

Ok, It would be helpful for us if it resolved as soon as possible.