How can I modify an existing Excel workbook with Perl?

后端 未结 4 1710
盖世英雄少女心
盖世英雄少女心 2021-01-02 12:04

With Spreadsheet::WriteExcel, I can create a new workbook, but what if I want to open an existing book and modify certain columns? How would I accomplish that?

I cou

4条回答
  •  轮回少年
    2021-01-02 12:29

    There's a section of the Spreadsheet::WriteExcel docs that covers Modifying and Rewriting Spreadsheets.

    An Excel file is a binary file within a binary file. It contains several interlinked checksums and changing even one byte can cause it to become corrupted.

    As such you cannot simply append or update an Excel file. The only way to achieve this is to read the entire file into memory, make the required changes or additions and then write the file out again.

    You can read and rewrite an Excel file using the Spreadsheet::ParseExcel::SaveParser module which is a wrapper around Spreadsheet::ParseExcel and Spreadsheet::WriteExcel. It is part of the Spreadsheet::ParseExcel package.

    There's an example as well.

提交回复
热议问题