Php Box / Spout格式单元格到货币和设置宽度

Php Box / Spout格式单元格到货币和设置宽度

问题描述:

After looking over the documentation for Box/Spout I do not see a way to format cells for currency.

NOTE: PhpExcel and PhpSpreadsheet are not an option.

Is there a way to format a cell?

While styling, is there a way to set the width of the cells?

This is my code so far.
It works, but is lacking currency formatting and width:

$writer = WriterFactory::create(Type::XLSX); // for XLSX files
$writer->openToFile($tmpfile); // write data to a file or to a PHP stream
$writer_sheet = $writer->getCurrentSheet();

$writer_sheet->setName($invoiceSheetName);
$headerStyle = (new StyleBuilder())
  ->setFontBold()
  ->setFontUnderline()
  ->build();

// add header with style
$writer->addRowWithStyle($header, $headerStyle);

$writer->addRows($resultsArray); // add multiple rows at a time
$writer->close();
$excelOutput = file_get_contents($tmpfile);

Documentation: Spout Documentation

Help is greatly appreciated.

查看Box / Spout的文档后,我没有看到格式化货币单元格的方法。 p>

注意:PhpExcel和PhpSpreadsheet不是一个选项。 p>

有没有办法格式化单元格? p> 在设置样式时,有没有办法设置单元格的宽度? p>

这是我的代码到目前为止。
它有效,但缺少货币格式和宽度: p>

  $ writer = WriterFactory :: create(Type :: XLSX);  //对于XLSX文件
 $ writer-> openToFile($ tmpfile);  //将数据写入文件或PHP流
 $ writer_sheet = $ writer-> getCurrentSheet(); 
 
 $ writer_sheet-> setName($ invoiceSheetName); 
 $ headerStyle =(new StyleBuilder(  ))
  - > setFontBold()
  - > setFontUnderline()
  - > build(); 
 
 //添加带有样式的标题
 $ writer-> addRowWithStyle($ header,$  headerStyle); 
 
 $的写入器的> addRows($ resultsArray);  //一次添加多行
 $ writer-> close(); 
 $ excelOutput = file_get_contents($ tmpfile); 
  code>  pre> 
 
 

文档:\ n Spout Documentation p>

非常感谢帮助。 p> div>

Decided to implement my own implementation with unzipping the xlsx file and modifying the correct xml file.