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

Free Support Forum - aspose.com

Cell style doesn't show when converting to pdf

Hi,

We have an issue while saving our excel file to pdf.

We use an excel (xlsx) template and use putvalue to add our data into the ranges (the data is numeric and cast to doubles). We tried exporting the generated file to excel 2007 and to pdf. If the cell that we are trying to fill has a cell formatting it just shows 0 in the pdf file but the correct value in the excel 2007 file. The excel format we are trying to use is: € #.##0,00

We are currently using Aspose.Cells version 5.0.0.0

We use the following code to save our files:

this.Workbook = new Workbook();
Workbook.Open(ExcelPath);
SetData(Workbook);
Workbook.CalculateFormula();
byte[] returnValue = null;
byte[] returnValue2 = null;
using (MemoryStream stream = new MemoryStream())
{
Workbook.Save(stream, FileFormatType.Pdf);
returnValue = stream.ToArray();
stream.Close();
}
using (MemoryStream stream = new MemoryStream())
{
Workbook.Save(stream, FileFormatType.Excel2007Xlsx);
returnValue2 = stream.ToArray();
stream.Close();
}
using (Stream output = new FileStream(@“e:\temp.pdf”,
FileMode.Create))

{

output.Write(returnValue, 0, returnValue.Length);

output.Flush();

output.Close();

}
using (Stream output = new FileStream(@“e:\temp.xlsx”, FileMode.Create))
{
output.Write(returnValue2, 0, returnValue2.Length);
output.Flush();
output.Close();
}

Hi,

Kindly post your generated Excel 2007 and PDF files here, we will check your issue soon.

Thank you.

You can find 3 files in the zip.
paf2.pdf --> generated pdf file
paf2.xlsx --> generated xlsx file
PafTemplate.xlsx --> the template file
cell L23 has a format set


Hi,

Please try the attached version and let us know if it works fine now.

Thank you.

Thanks a lot, it works now :slight_smile: