1

I'm losing leading zeros on zipcodes when generating pdfs via Aspose. I've come to the conclusion that Excel is formatting the cells with zipcodes as a number, which strips any leading zeros. The Aspose documentation explains how to format a cell as text by using the number property of the style object, with "49" being the value for text. My code attempting to format cell B7 as a number reads as such:

cell.ImportDataTable(table, true, 5, 0, table.Rows.Count, table.Columns.Count, true, "mm/dd/yyyy", true);
    Style style = cell["B7"].GetStyle();
            style.Number = 49;
            cell["B7"].SetStyle(style);

The "table" argument in the ImportDataTable method contains a zipcode with a leading zero. After generating the pdf, cell B7 does in fact have the correct text format applied to it but the value still does not include the leading zero. Am I applying this formatting incorrectly or at the wrong place in the life cycle?

0

1 Answer 1

1

The last parameter of ImportDataTable() method controls the formatting of imported numbers. Set it to false and you will have the leading zeroes in the imported cells, as well as in the generated PDF.

cell.ImportDataTable(table, true, 5, 0, table.Rows.Count, table.Columns.Count, true, "mm/dd/yyyy", false);

I work with Aspose as Developer Evangelist.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.