I'm using the Pear Excel Writer package to export a dataset to Excel from PHP. My problem is some of the data fields have leading zeros (such as a zip code), but these are being trimmed in Excel. I tried adding an apostrophe to the start of the fields to force a text field, but then Excel displays it, which I don't want. I'm neither a PHP nor Excel expert, but I expect I'm missing something relatively simple. Any ideas?
问问题
1452 次
1 回答
1
要在 excel 中显示前导零,您必须应用自定义数字格式。对于固定长度的数字 - 您的情况 - 这类似于00000
(对于 5 位数字),对于可变长度的数字类似于"000"#
(带有 3 个前导零的数字)。此 excel 格式应由Spreadsheet_Excel_Writer
. 如果没有,您可以使用Format::setNumFormat
.
于 2009-12-04T17:12:32.943 回答