Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Tue Oct 11, 2022 7:07 am

Hello Experts,

Im converting XLSX file into PDF file using spire.xls-12.9.1 API.

Sample code, sample source file and the image of exact error highlighted are attached for your reference.

balance-sheet.xlsx has 3 columns merged and displayed value as Company Name. But after conversion, this value has been shrinked into a single middle column. But the value is not displayed fully. Attached image file (Balance Sheet Img.png) for your reference.

I really appreciate your help on this.
Attachments
ConvertExcelToPdf-Cell.zip
(255.23 KiB) Downloaded 214 times

UshaThavasiappan
 
Posts: 109
Joined: Sat Oct 08, 2022 9:23 am

Tue Oct 11, 2022 8:53 am

Hello,

Thanks for your inquiry.
After investigation, I didn’t reproduce your issue when using your code and Spire.Xls 12.9.1 to do a test. I attached my result Pdf document for your reference. Please make sure that you are using Spire.Xls 12.9.1. If you do use Spire.Xls 12.9.1, please offer the following message to help us reproduce your issue and work out a solution for you. Thanks for your assistance in advance.

1) The Jdk version, such as Oracle Jdk1.8
2) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).

PS: My test environment is Win10-64bit and Oracle Jdk1.8.

Sincerely
Abel
E-iceblue support team
Attachments
balance-sheet.zip
The result Pdf document for your reference
(132.01 KiB) Downloaded 82 times
User avatar

Abel.He
 
Posts: 951
Joined: Tue Mar 08, 2022 2:02 am

Tue Oct 11, 2022 12:31 pm

Hello Abel,

Im using Spire.Xls 12.9.1 version only.

My test environment is Windows 11 - 64bit and JDK 17.0.2. Even I tried with JDK 1.8, but im getting the same issue

Update : I also tried with Windows 10 - 64 bit and JDK 15.0.2, but no luck

UshaThavasiappan
 
Posts: 109
Joined: Sat Oct 08, 2022 9:23 am

Wed Oct 12, 2022 10:22 am

Hello,

Thanks for your feedback.
Have you had this problem testing on other operating systems(such as Win10 .etc)? In addition, please offer the “scale and layout” of your computer, as shown in the screenshot below. Looking forward to your reply.

Sincerely
Abel
E-iceblue support team
Attachments
111.png
111.png (35.09 KiB) Viewed 472 times
User avatar

Abel.He
 
Posts: 951
Joined: Tue Mar 08, 2022 2:02 am

Thu Oct 13, 2022 4:47 am

Win-Scale.png
Win-Scale.png (33.16 KiB) Viewed 467 times

Hello,
Yes, I'm also having the same scale. Please refer the attached screenshot

UshaThavasiappan
 
Posts: 109
Joined: Sat Oct 08, 2022 9:23 am

Thu Oct 13, 2022 6:40 am

Hello,
Even I tried with CentOS Linux version 7 with Open JDK 1.8.0_222.
I'm still facing the same issue.

UshaThavasiappan
 
Posts: 109
Joined: Sat Oct 08, 2022 9:23 am

Thu Oct 13, 2022 10:35 am

Hello,

Thanks for your feedback.
I tested the scenario on CentOS Linux version 7 and also didn’t reproduce your issue. I put my test jar file to our server, you can download it from the following link and have a test. In addition, please offer your test complete project to help us do further investigation. Thanks for your assistance in advance.

https://www.e-iceblue.com/downloads/att ... /31068.zip

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 951
Joined: Tue Mar 08, 2022 2:02 am

Thu Oct 13, 2022 4:32 pm

Hello,
I have attached actual source code with the issue. Please through a light on the same and let me know you could reproduce my issue.

ConvertExcelToPdf-Cell.zip
(255.28 KiB) Downloaded 71 times

UshaThavasiappan
 
Posts: 109
Joined: Sat Oct 08, 2022 9:23 am

Fri Oct 14, 2022 10:34 am

Hello,

Thanks for your feedback.
Through your comments on other posts, I guess that you use the following code before converting excel to pdf, if so, please refer to the following code to achieve the effect you wanted. However, if my guess is wrong, please offer a simple Java project, you can create a simple console project that can reproduce your issue. The project may be a big file, you could upload your large file via Dropbox or OneDrive server, then share us with the download link.

In addition, how is the jar file I provided running on your side?
Looking forward to your reply.

Code: Select all
//Create a Workbook instance and load an Excel file
Workbook workbook = new Workbook();
workbook.loadFromFile("data/balance-sheet.xlsx");

workbook.getConverterSetting().setSheetFitToWidth(true);
//Set worksheets to fit to page when converting
workbook.getConverterSetting().setSheetFitToPage(true);

//Save the resulting document to a specified path
workbook.saveToFile("output/balance-sheet.pdf", FileFormat.PDF);


Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 951
Joined: Tue Mar 08, 2022 2:02 am

Fri Oct 14, 2022 11:12 am

Hi Abel,
Yeah, the jar file you provided was working.

Actually I'm iterating the sheets to set autoFitRows and autoFitColumns for my business need.
The cell data are clipped when not using these autoFit methods.

But when I try to iterate all the sheets in the workbook and used autoFitColumns and autoFitRows methods, I got real issue. Could you please try the below code snippet for once.

Code: Select all
Workbook workbook = new Workbook();
workbook.loadFromFile("E:\\balance-sheet.xlsx");

workbook.getConverterSetting().setSheetFitToWidth(true);
workbook.getConverterSetting().setSheetFitToPage(true);

for (int i = 0; i < workbook.getWorksheets().size(); i++) {
   Worksheet worksheet = workbook.getWorksheets().get(i);
   worksheet.getAllocatedRange().autoFitColumns();
   worksheet.getAllocatedRange().autoFitRows();
}

workbook.saveToFile("E:\\output-balance-sheet.pdf", FileFormat.PDF);
workbook.dispose();

UshaThavasiappan
 
Posts: 109
Joined: Sat Oct 08, 2022 9:23 am

Mon Oct 17, 2022 11:06 am

Hello,

Thanks for your feedback.
After further investigation. If you set “auto fit row height” and “auto fit column width” for worksheet in MS Excel then save file to Pdf file, the result pdf file is the same as the result pdf document generated by our products when setting “auto fit row height” and “auto fit column width”. Our product follows the Microsoft specification, so it isn’t a product bug.
In addition, for the clipped issue, I noticed your feedback to lisa, we will give you reply asap.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 951
Joined: Tue Mar 08, 2022 2:02 am

Mon Oct 17, 2022 12:05 pm

Hello,
Thanks for your reply. I will follow that discussion for solution.

UshaThavasiappan
 
Posts: 109
Joined: Sat Oct 08, 2022 9:23 am

Tue Oct 18, 2022 2:02 am

Hello,

Thanks for your feedback.
If you have any issue, just feel free to contact us.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 951
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.XLS