免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4673 | 回复: 5
打印 上一主题 下一主题

求perl对excel 操作代码 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-05-04 20:50 |只看该作者 |倒序浏览
请问各位前辈,如何使用perl 操作excel ???
比如我想删除file A 中的 第六列任意元素与中fileB 中第四列任意元素相同的fileA的 行
file A
                 第六列  
丁玉洁     18755323055
周江  18610019611
汤新景  18911258305
鲁理平  13126719757
郭林青  15910552285
薄祥洁  13664401866
file B
                  第四列
王青华    13664401866
刘瑶瑶    12389581064
徐龙华    13531521634
胡高爽    13924154657
魏学玲    15641253478
韩中惠    14253856990
石磊       31433266458
赵涛       14136548679

其中A 的丁玉洁号码与B 的王青华号码重了, 我想讲A 中的重的这个人的所有信息也就是这一行都删除,该怎么实现呢?

论坛徽章:
46
15-16赛季CBA联赛之四川
日期:2018-03-27 11:59:132015年亚洲杯之沙特阿拉伯
日期:2015-04-11 17:31:45天蝎座
日期:2015-03-25 16:56:49双鱼座
日期:2015-03-25 16:56:30摩羯座
日期:2015-03-25 16:56:09巳蛇
日期:2015-03-25 16:55:30卯兔
日期:2015-03-25 16:54:29子鼠
日期:2015-03-25 16:53:59申猴
日期:2015-03-25 16:53:29寅虎
日期:2015-03-25 16:52:29羊年新春福章
日期:2015-03-25 16:51:212015亚冠之布里斯班狮吼
日期:2015-07-13 10:44:56
2 [报告]
发表于 2015-05-05 09:49 |只看该作者
Perl 有处理 excel 的模块但是我不会用啊,上 metacpan.org 上面搜 excel 就能找到。这要是csv格式的话 Perl 做起来还是很简单的

论坛徽章:
12
子鼠
日期:2014-10-11 16:46:482016科比退役纪念章
日期:2018-03-16 10:24:0515-16赛季CBA联赛之山东
日期:2017-11-10 14:32:142016科比退役纪念章
日期:2017-09-02 15:42:4715-16赛季CBA联赛之佛山
日期:2017-08-28 17:11:5515-16赛季CBA联赛之浙江
日期:2017-08-24 16:55:1715-16赛季CBA联赛之青岛
日期:2017-08-17 19:55:2415-16赛季CBA联赛之天津
日期:2017-06-29 10:34:4315-16赛季CBA联赛之四川
日期:2017-05-16 16:38:55黑曼巴
日期:2016-07-19 15:03:112015亚冠之萨济拖拉机
日期:2015-05-22 11:38:5315-16赛季CBA联赛之北京
日期:2019-08-13 17:30:53
3 [报告]
发表于 2015-05-22 11:39 |只看该作者
楼上是故意的

论坛徽章:
71
子鼠
日期:2015-06-10 14:07:09丑牛
日期:2015-06-10 14:07:10寅虎
日期:2015-06-10 14:07:40卯兔
日期:2015-06-10 14:07:44辰龙
日期:2015-06-10 14:07:44巳蛇
日期:2015-06-10 14:07:46午马
日期:2015-06-10 14:07:47未羊
日期:2015-06-10 14:07:48申猴
日期:2015-06-10 14:07:50酉鸡
日期:2015-06-10 14:07:54戌狗
日期:2015-06-10 14:07:55亥猪
日期:2015-06-10 14:07:57
4 [报告]
发表于 2015-05-22 13:02 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
5 [报告]
发表于 2015-05-24 08:19 |只看该作者
楼上是故意的

论坛徽章:
0
6 [报告]
发表于 2015-06-06 08:05 |只看该作者
本帖最后由 yaohuabing 于 2015-06-06 08:06 编辑

perl处理excel最常用的module是
Spreadsheet::WriteExcel (生成新的excel) 和
Spreadsheet::ParseExcel(读excel)
在WriteExcel的文档里关于修改已有的excel,有这么一段:

MODIFYING AND REWRITING EXCEL FILES

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: search.cpan.org/search?dist=Spreadsheet-ParseExcel.

However, you can only rewrite the features that Spreadsheet::WriteExcel supports so macros, graphs and some other features in the original Excel file will be lost. Also, formulas aren't rewritten, only the result of a formula is written.

按照你的需求,最好的办法就是读这两个excel文件,匹配内容,然后生成新的excel文件
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP