XLSX转为CSV - 回调模式

优质
小牛编辑
138浏览
2023-12-01
putCSVCallback(callable $callback, resource $handler): bool

callable $callback
$config   = ['path' => './tests'];
$excel    = new \Vtiful\Kernel\Excel($config);
$filePath = $excel->fileName('tutorial.xlsx', 'TestSheet1')
    ->header(['String', 'Int', 'Double'])
    ->data([
        ['Item_1', 10, 10.9999995],
    ])
    ->output();
​
$fp = fopen('./tests/file.csv', 'w');
​
$csvResult = $excel->openFile('tutorial.xlsx')
    ->openSheet()
    ->putCSVCallback(function(array $row){
        return $row;
    }, $fp);