函数原型

  1. insertText(int $row, int $column, string|int|double $data[, string $format, resource $formatHandler])

int $row

单元格所在行

int $column

单元格所在列

string | int | double $data

需要写入的内容

string $format

内容格式

resource $formatHandler

单元格样式

示例

  1. $excel = new \Vtiful\Kernel\Excel($config);
  2. $textFile = $excel->fileName("free.xlsx")
  3. ->header(['name', 'money']);
  4. for ($index = 0; $index < 10; $index++) {
  5. $textFile->insertText($index+1, 0, 'viest');
  6. $textFile->insertText($index+1, 1, 10000, '#,##0'); // #,##0 为单元格数据样式
  7. }
  8. $textFile->output();

数字样式示例

更多样式请参考 Excel 微软文档

  1. "0.000"
  2. "#,##0"
  3. "#,##0.00"
  4. "0.00"
  5. "0 \"dollar and\" .00 \"cents\""