【问题标题】:Is it possible to write in an existing spreadSheet with PhpSpreadSheet?是否可以使用 PhpSpreadSheet 在现有的电子表格中写入?
【发布时间】:2018-11-09 13:36:49
【问题描述】:

我目前正在使用 PhpSpreadSheet 库,我想写入现有的电子表格。那可能吗?

如果是,如何?我在documentation 中没有看到任何可能性。

谢谢!

【问题讨论】:

    标签: php spreadsheet phpspreadsheet


    【解决方案1】:
    • 加载现有的电子表格文件
    • 改变一些东西
    • 再次写入文件系统

    代码:

    <?php
    
    //load spreadsheet
    $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load("yourspreadsheet.xlsx");
    
    //change it
    $sheet = $spreadsheet->getActiveSheet();
    $sheet->setCellValue('A1', 'New Value');
    
    //write it again to Filesystem with the same name (=replace)
    $writer = new Xlsx($spreadsheet);
    $writer->save('yourspreadsheet.xlsx');
    

    【讨论】:

    • 文档与@Evil_skunk ... 非常感谢您... wtf doc phpspreadsheet 这是???????????我一直在寻找这个答案,比如 20 分钟
    猜你喜欢
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-16
    • 2018-08-24
    • 1970-01-01
    • 2019-07-15
    相关资源
    最近更新 更多