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

Free Support Forum - aspose.com

Using Aspose.Cells and saving in PDF Format does not show number format correctly

I am using Aspose.Cells and I am trying to save a workbook in PDF format. The issue I am having is that I am trying to set the number style on a cell to include a comma separator or any kind of number formatting for that matter, if I save the file as an standard xls type the format of the cell is correct. If I try to save the format as PDF the number style is lost, the other styling on the cell is still correct like the background color, just the number styling is lost when saved as a pdf file. Here is the code I am using to set the number style:

protected void PutIntValue(Cell cell, object dbValue)
{
Style style = cell.GetStyle();
style.Number = 3;
if (dbValue != DBNull.Value)
{
cell.PutValue(Utilities.DataSetUtilities.IntValue(dbValue));
cell.SetStyle(style);
}
}

Hi,

Please share the excel workbook and the complete code that you are using.

Hi,

I have tested your scenario using the following sample code and it works fine.

Sample code:
Workbook wb = new Workbook();
Worksheet worksheet = wb.Worksheets[0];
Cells cells = worksheet.Cells;

Style style;

for (int i = 0; i < 22; i++)
{
cells[i, 0].PutValue(i + 1000);
style = cells[i,0].GetStyle();
style.Number = 3;
cells[i, 0].SetStyle(style);

}
wb.Save(“e:\test\mypdf.pdf”);
wb.Save(“e:\test\myexcel.xls”);

I am using latest version/fix of the product Aspose.Cells for .NET v5.0.0.12, you may get it from the thread and try it:
http://www.aspose.com/community/forums/2/248339/saving-to-pdf.troubles-with-font/showthread.aspx

If you still find the issue, kindly share your generated Excel file or sample code (as suggested by Salman Shakeel) here, we will check your case and test the conversion(Xls2PDF) soon.


Thank you.

Thanks,

Using the latest build 5.0.0.12 fixed the issue and the formatting shows correctly in the pdf file.