全局默认样式

设置全局默认样式,将会影响所有写入单元格的样式;

函数原型

  1. defaultFormat(resource $formatHandler)

resource $formatHandler

单元格样式

示例

  1. $config = ['path' => './tests'];
  2. $excel = new \Vtiful\Kernel\Excel($config);
  3. $excel->fileName('tutorial.xlsx');
  4. $format = new \Vtiful\Kernel\Format($excel->getHandle());
  5. $colorOneStyle = $format
  6. ->fontColor(\Vtiful\Kernel\Format::COLOR_ORANGE)
  7. ->border(\Vtiful\Kernel\Format::BORDER_DASH_DOT)
  8. ->toResource();
  9. $format = new \Vtiful\Kernel\Format($excel->getHandle());
  10. $colorTwoStyle = $format
  11. ->fontColor(\Vtiful\Kernel\Format::COLOR_GREEN)
  12. ->toResource();
  13. $filePath = $excel
  14. // Apply the first style as the default
  15. ->defaultFormat($colorOneStyle)
  16. ->header(['hello', 'xlswriter'])
  17. // Apply the second style as the default style
  18. ->defaultFormat($colorTwoStyle)
  19. ->data([
  20. ['hello', 'xlswriter'],
  21. ])
  22. ->output();