How to automatic resizing the content from Excel to PDF

Hi all,

How can I merge the content from Excel into PDF?
I success convert the file format, but the content is not in the exactly column and row.
Anyone can help me solve this problem? Thanks a lot

Hi Christlynn,

Thanks for your posting and using Aspose.Cells.

Aspose.Cells provide Worksheet.AutoFitRows() and Worksheet.AutoFitColumns() which you can be used to make rows and columns to autofit correctly as per contents of the cells.

Mostly, you use Worksheet.AutoFitRows() before converting Excel to PDF. For example see the following code.

C#


//Load the workbook

Workbook workbook = new Workbook(“source.xlsx”);


//Access the first worksheet

Worksheet worksheet = workbook.Worksheets[0];


//AutoFit rows

worksheet.AutoFitRows();


//Save the workbook into pdf

workbook.Save(“output.pdf”);

Thanks for your reply.
If in Java? I using Eclipse, it doesnt support the .AutoFitRows();

Hi Christlynn,

Thanks for your posting and using Aspose.Cells.

Here is the Java equivalent of the above code. Please add the Aspose.Cells Jar file in your classpath. Please download it from the latest version: Aspose.Cells for Java 8.1.1.

Java


//Load the workbook

Workbook workbook = new Workbook(“source.xlsx”);


//Access the first worksheet

Worksheet worksheet = workbook.getWorksheets().get(0);


//AutoFit rows

worksheet.autoFitRows();


//Save the workbook into pdf

workbook.save(“output.pdf”);