viest / php-ext-xlswriter

🚀 PHP Extension for creating and reader XLSX files.
https://xlswriter.viest.me
BSD 2-Clause "Simplified" License
2.25k stars 232 forks source link

xlsx转csv 身份证、手机号 变成科学记数法 #485

Closed siyue1314 closed 1 year ago

siyue1314 commented 1 year ago
image image
viest commented 1 year ago

可以通过 setType 设置每列的类型,示例:

$config = ['path' => '/path'];
$excel  = new \Vtiful\Kernel\Excel($config);

$fp = fopen('/path/file.csv', 'w');

$excel->openFile('filename.xlsx')
    ->openSheet()
    ->setType([
        \Vtiful\Kernel\Excel::TYPE_STRING,
        \Vtiful\Kernel\Excel::TYPE_STRING,
        \Vtiful\Kernel\Excel::TYPE_STRING,
        \Vtiful\Kernel\Excel::TYPE_STRING,
        \Vtiful\Kernel\Excel::TYPE_STRING,
        \Vtiful\Kernel\Excel::TYPE_STRING,
    ])
    ->putCsv($fp);