开发者社区> 问答> 正文

用PHP读写XLSM文件

我想使用PHP 读写XLSM类型的文件。我尝试为此使用PHPSpreadsheet,但它不支持XLSM扩展。

一种可能的解决方案是使用EasyXLS(https://www.easyxls.com/manual/basics/import-from-xlsx-file-format.html)

$workbook = new COM("EasyXLS.ExcelDocument");

// Import XLSM file
$workbook->easy_LoadXLSXFile("C:\\Samples\\Excel to import.xlsm");

// Get the table of the second worksheet
$xlsSecondTable = $workbook->easy_getSheet("Second tab")->easy_getExcelTable();

// Add more data to the second sheet
$xlsSecondTable->easy_getCell_2("A1")->setValue("Data added by Tutorial37");
for ($column=0; $column<5; $column++)
{
    $xlsSecondTable->easy_getCell(1, $column)->setValue("Data " . ($column + 1));
}

// Generate the XLSM file
$workbook->easy_WriteXLSXFile("C:\Samples\Excel with macro.xlsm");

但是我无法为此找到任何库。

有人对此有任何可能的解决方案吗?

展开
收起
社区秘书 2019-11-27 16:25:13 2742 0
1 条回答
写回答
取消 提交回答
  • github.com/xuri

    推荐一个功能丰富、兼容性好、高性能的 Excel 文档基础库 Excelize:https://github.com/xuri/excelize https://xuri.me/excelize/images/excelize.svg

    2020-12-08 11:37:28
    赞同 2 展开评论 打赏
问答分类:
PHP
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
阿里云栖开发者沙龙PHP技术专场-深入浅出网络编程与swoole内核-吴镇宇 立即下载
PHP安全开发:从白帽角度做安全 立即下载
PHP 2017.北京 全球开发者大会——高可用的PHP 立即下载