用于xlsx的phpexcel千分隔符 [英] phpexcel thousand separator for xlsx
本文介绍了用于xlsx的phpexcel千分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用
\PHPExcel_Shared_String::setThousandsSeparator(',');
为Excel文件定义一千个分隔符。感谢它,一个单元格显示为 55 452
,而不是 55452
。仍然,单元格值是整数55452,因此可以在图表中进行计算。
to define a thousand separator for Excel file. Thanks to it, a cell is displayed as 55 452
instead of 55452
. Still, the cell value is an integer 55452, so it can be calculated, used within charts, etc.
是否有类似的方法来定义一个百万分隔符,等等(例如,定义每个3位数字的分隔符)?
Is there a similar way to define a million separator and so on (e.g. to define a separator each 3 digits)?
推荐答案
您需要定义数字格式,如#,#0。 ##; [Red] - #,#0。##
You need to define number format like this "#,#0.##;[Red]-#,#0.##"
$workbook = new Spreadsheet_Excel_Writer('example.xls');
$worksheet =& $workbook->addWorksheet("example_sheet_name");
$format =& $workbook->addFormat();
$format->setNumformat('#,#0.##;[Red]-#,#0.##');
$worksheet->writeNumber(1, 1, '100000',$format);
output : 100.000,00
这篇关于用于xlsx的phpexcel千分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文