使用libxlsxwriter库写入文件。
开发中...
phpize
./configure --with-php-config=php-config
make
make install
$book = new ExcelBook('用户表.xlsx');
$sheet = $book->addSheet();
$sheet->addColumn('ID', 'id', ExcelColumn::FORMAT_NUMBER);
$sheet->addColumn('姓名', 'name');
$sheet->addColumn('手机', 'mobile', ExcelColumn::FORMAT_STRING);
$sheet->addColumn('金额', function($data){
return $data['money'] - $data['frozen_money'];
}, ExcelColumn::FORMAT_NUMBER);
$data = [
['id' => 1, 'name' => 'ChienHo', 'mobile' => '134*******0', 'money' => 100, 'frozen_money' => 1],
['id' => 2, 'name' => 'Johnny', 'mobile' => '138*******3', 'money' => 13, 'frozen_money' => -1],
];
$sheet->writeByArray($data);
$book->save();