.xlsx到.csv与phpexcel创建只读.csv文件

时间:2015-01-23 13:29:54

标签: php csv phpexcel

我正在使用phpexcel库将.xlsx文件url-list-with-change-in-page-size.xlsx转换为url-list-with-change-in-page-size.csv文件。

我的代码看起来:

<?
/** SCRIPT SETTINGS */
error_reporting(E_ALL);

/** PHPExcel */
require_once 'PHPExcel.php'; // (this should include the autoloader)
require_once 'PHPExcel/IOFactory.php';

$excel_readers = array(
    'Excel5' , 
    'Excel2003XML' , 
    'Excel2007'
);



$reader = PHPExcel_IOFactory::createReader('Excel2007');
$reader->setReadDataOnly(true);

$path = '/opt/lampp/htdocs/Wdrive/url-list-with-change-in-page-size.xlsx';
$excel = $reader->load($path);

$writer = PHPExcel_IOFactory::createWriter($excel, 'CSV');
$writer->save('/opt/lampp/htdocs/Wdrive/url-list-with-change-in-page-size.csv');
?>

此代码成功生成.csv文件。但它正在制作read only file

有什么办法可以改变或修改这段代码来编写可编写的文件吗?

三江源

0 个答案:

没有答案