如何使用 Perl 修改现有的 Excel 工作簿? [英] How can I modify an existing Excel workbook with Perl?

查看:146
本文介绍了如何使用 Perl 修改现有的 Excel 工作簿?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Spreadsheet::WriteExcel,我可以创建一个新工作簿,但如果我想打开现有工作簿并修改某些列怎么办?我将如何做到这一点?

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?

我可以使用 Spreadsheet::ParseExcel 解析工作表中的所有数据 然后使用 <在某些行/列中用新值写回它但是,代码>电子表格::WriteExcel.有没有已经将两者结合的模块?

I could parse all of the data out of the sheet using Spreadsheet::ParseExcel then write it back with new values in certain rows/columns using Spreadsheet::WriteExcel, however. Is there a module that already combines the two?

主要是我只想打开一个.xls,覆盖某些行/列,然后保存.

Mainly I just want to open a .xls, overwrite certain rows/columns, and save it.

推荐答案

Spreadsheet::ParseExcel 将读取现有的 excel 文件:

Spreadsheet::ParseExcel will read in existing excel files:

my $parser   = Spreadsheet::ParseExcel->new();
# $workbook is a Spreadsheet::ParseExcel::Workbook object
my $workbook = $parser->Parse('Book1.xls');

但您真正想要的是电子表格::ParseExcel::SaveParser,它是 Spreadsheet::ParseExcel 的组合和 Spreadsheet::WriteExcel.文档底部附近有一个示例.

But what you really want is Spreadsheet::ParseExcel::SaveParser, which is a combination of Spreadsheet::ParseExcel and Spreadsheet::WriteExcel. There is an example near the bottom of the documentation.

这篇关于如何使用 Perl 修改现有的 Excel 工作簿?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆