PHP SimpleXLSX 无法读取 excel(.xlsx) 文件
PHP SimpleXLSX can not read excel(.xlsx) file
SimpleXLSX can not read excel file that generated using PHP_XLSXWriter.
XLSXWriter代码:
header('Content-Disposition: attachment; filename="'.XLSXWriter::sanitize_filename($file_name).'"');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=utf-8');
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Expires: 0");
header("Cache-Control: private",false);
$writer = new XLSXWriter();
$writer->writeToFile(DIR_EXCEL . $file_name) //file path in bracket
SimpleXLSX can read manually generated Excel(.xlsx) file.
需要在 SimpleXLSX.php 文件中添加这些行。
const SCHEMA_REL_RELATIONSHIP = 'http://schemas.openxmlformats.org/package/2006/relationships';
const SCHEMA_REL_OFFICEDOCUMENT_RELATIONSHIP = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships';
const SCHEMA_REL_WORKSHEETRELATION = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet';
SimpleXLSX can not read excel file that generated using PHP_XLSXWriter.
XLSXWriter代码:
header('Content-Disposition: attachment; filename="'.XLSXWriter::sanitize_filename($file_name).'"');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=utf-8');
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Expires: 0");
header("Cache-Control: private",false);
$writer = new XLSXWriter();
$writer->writeToFile(DIR_EXCEL . $file_name) //file path in bracket
SimpleXLSX can read manually generated Excel(.xlsx) file.
需要在 SimpleXLSX.php 文件中添加这些行。
const SCHEMA_REL_RELATIONSHIP = 'http://schemas.openxmlformats.org/package/2006/relationships';
const SCHEMA_REL_OFFICEDOCUMENT_RELATIONSHIP = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships';
const SCHEMA_REL_WORKSHEETRELATION = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet';