« LAMP 体系下 mysql 数据库目录的权限问题 | Main | 为 apache 添加 SSL 支持 »
December 24, 2006
用 Spreadsheet::ParseExcel 处理中文 excel 文件
|
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明。 http://windtear.net/archives/2006/12/24/001173.html http://windtear.net/archives/2006/12/24/001173.html 用 Spreadsheet::ParseExcel 处理中文 excel 文件 perldoc Spreadsheet::ParseExcel 介绍的很详细了 中文 excel 处理需要稍微多做一步 用 Spreadsheet::ParseExcel::FmtUnicode 指定 Unicode_Map 为 CP936 然后直接调用 Parse 方法就行了 返回值是一个关键数组 内容就是 excel 文件的内容 如 $oBook->{File} 是文件名 $oBook->{SheetCount} 是sheet个数 $oBook->{Worksheet}[0]->{Name} 是第一个 sheet 的名字 $oBook->{Worksheet}[1]->{MaxRow} 是第二个 sheet 的最大行 $oBook->{Worksheet}[2]->{Cells}[1][0]->{Val} 是第三个 sheet 的第二行第一列的值 $oBook->{Worksheet}[2]->{Cells}[1][0]->Value 是第三个 sheet 的第二行第一列的转化后的中文值 use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::FmtUnicode; my $oExcel = new Spreadsheet::ParseExcel; my $oCode = "CP936"; my $oFmtJ = Spreadsheet::ParseExcel::FmtUnicode->new(Unicode_Map => $oCode); my $oBook = $oExcel->Parse($excelFile, $oFmtJ); 然后根据情况 循环sheet 行/row 列/column 处理就行了 |
Posted by windtear at December 24, 2006 10:37 PM
Trackback Pings
TrackBack URL for this entry:
http://cgi.windtear.net/cgi-bin/wt-tb.cgi/1173
Comments
Post a comment
【我爱网络】
2007-12-31 23:51 2007年度 ipcn.org/ipchina.org 总结报告
2007-12-31 00:31 vmware gsx server service
2007-12-31 00:15 squid 对 404 302 缓存的相关问题
2007-12-30 14:24 升级到 MovableType 3.3x 并修改 entry_basename 兼容性
2007-12-30 13:52 [php] realip judge 前面补0的ip格式剔除
2007-12-14 16:34 rm -rf * 系统管理员要排查的定时炸弹
2007-12-13 19:03 山西的宽带运营商太过分了 私自窜改dns解析
2007-12-13 16:35 F5 MIB 再学习 唯一性标记用地址的小bug
2007-12-11 22:15 perl 用Spreadsheet::WriteExcel写了个处理/读写excel的小程序
2007-12-11 13:39 perl 变量转义的问题