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

Free Support Forum - aspose.com

Excel to PDF some cell data display abnormal

I have a excel that contail big number and date in cell,it display like file1.png.
I want to show the real value after convert to pdf file, but it display like file2.png.
Please tell me How can it show the real value after convert to pdf?
the version is Aspose.PDF for .Net 21.6.0.0.
file2.png (12.6 KB)
file1.png (3.8 KB)
The Excel file:
oragin.7z (8.8 KB)
The output PDF file:
output.pdf (29.8 KB)

@sullivan,

If you could open the file into MS Excel manually and save it as “Pdf”, you will also notice the same display as of PDF generated by Aspose.Cells. You can see it is MS Excel’s behavior to display long (double) value in scientific notations (as in the case for A2 cell). Also, for datetime value, since the value is too long for cell (B column) width, so MS Excel displays it as “#####…”. To cope with original (number) value (for id column) to be displayed, you may specify/apply the numbers formatting before rendering to PDF. Moreover, to display complete value instead of showing “#####…”, you may either extend the columns width or call AutoFitColumns method on the worksheet before rendering to PDF. See the following sample code and try it for your requirements:
e.g.
Sample code:

            Workbook workbook = new Workbook("e:\\test2\\oragin.xlsx");
            //Get the first worksheet in the workbook.
            Worksheet worksheet = workbook.Worksheets[0];
            //Define a style object adding a new style 
            //to the collection list. 
            Style stl = workbook.CreateStyle(); ;
            //Set the integer format.
            stl.Custom = "0";
            //Set the style flag struct.
            StyleFlag flag = new StyleFlag();
            //Apply the number format.
            flag.NumberFormat = true;
            //Apply the style to first column
            worksheet.Cells.ApplyColumnStyle(0, stl, flag);
            
            //Extend columns widths
            worksheet.Cells.SetColumnWidth(0,17);
            worksheet.Cells.SetColumnWidth(1,15);

            //Autofit columns
            //worksheet.AutoFitColumns();

            //Save the file.
            workbook.Save("e:\\test2\\out1.pdf"); 

Hope, this helps a bit.

Thank you very much!

@sullivan,

You are welcome.