采用: perl -MCPAN -e 'install Spreadsheet::ParseExcel"' 安装CPAN的包。<br>如果安装有问题,直接cd /your_binary; make install就可以。<br>测试程序见下面: 给我发邮件付费吧。希望你是个诚实的人哦!!经过测试!!<br>#!/usr/bin/perl<br><br>use Spreadsheet::ParseExcel;<br>
use Spreadsheet::ParseExcel::SaveParser;<br><br>die "please input your excel file!\n" if(@ARGV<1);<br>my $file = $ARGV[0];<br>my $excel = new Spreadsheet::ParseExcel::SaveParser;<br>my $oBook = $excel->Parse($file);
<br>my @data=('jim','ford');<br>#format: the insert data will use this format<br>my $iFmt = $oBook->{Worksheet}[0]->{Cells}[0][0]->{FormatNo};<br>#Addcell():第几个表,行,列,数据,[格式可选]<br>#第一个表,第一行第二列插入数据,使用第一行第一列的格式。
<br>$oBook->AddCell(0, 0, 1, \@data, $iFmt);<br>#插入的这行没有格式<br>$oBook->AddCell(0, 1, 0, '304');<br>#插入的这行用单元格第一行第一列的格式<br>$oBook->AddCell(0, 1, 1, 'Kawai,Takanori', $iFmt);<br>#1.3 Save<br>$excel->SaveAs($oBook, $file); # as the same name
<br><br><br><br><div><span class="gmail_quote">2007/1/30, <a href="mailto:china-pm-request@pm.org">china-pm-request@pm.org</a> <<a href="mailto:china-pm-request@pm.org">china-pm-request@pm.org</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Send China-pm mailing list submissions to<br> <a href="mailto:china-pm@pm.org">china-pm@pm.org</a><br><br>To subscribe or unsubscribe via the World Wide Web, visit<br> <a href="http://mail.pm.org/mailman/listinfo/china-pm">
http://mail.pm.org/mailman/listinfo/china-pm</a><br>or, via email, send a message with subject or body 'help' to<br> <a href="mailto:china-pm-request@pm.org">china-pm-request@pm.org</a><br><br>You can reach the person managing the list at
<br> <a href="mailto:china-pm-owner@pm.org">china-pm-owner@pm.org</a><br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of China-pm digest..."<br><br><br>Today's Topics:
<br><br> 1. Re: China-pm Digest, Vol 21, Issue 3 (Jim Zhang)<br> 2. Re: China-pm Digest, Vol 21, Issue 3 (Jeff Pang)<br> 3. Re: Want to get a module (Wan)<br> 4. Re: Want to get a module (Jeff Pang)<br> 5. Re: Want to get a module (Jeff Pang)
<br> 6. Re: Want to get a module (Dongxu Ma)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Tue, 30 Jan 2007 14:11:41 +0800<br>From: "Jim Zhang" <
<a href="mailto:jim.zhang.china@gmail.com">jim.zhang.china@gmail.com</a>><br>Subject: Re: [PerlChina] China-pm Digest, Vol 21, Issue 3<br>To: <a href="mailto:china-pm@pm.org">china-pm@pm.org</a><br>Message-ID:<br> <
<a href="mailto:1f1ee1a60701292211n504c6ac9sb100da989b31ecb2@mail.gmail.com">1f1ee1a60701292211n504c6ac9sb100da989b31ecb2@mail.gmail.com</a>><br>Content-Type: text/plain; charset="iso-8859-1"<br><br>please clarify your meaning:
<br><br>&export_to_excel($filename, $location, \@data_array);<br><br>$location is, for example, "B2",which means Column B, Row 2.<br>@data_array looks like:<br>@AoA = (<br> [ "fred", "barney" ],
<br> [ "george", "jane", "elroy" ],<br> [ "homer", "marge", "bart" ],<br> );<br><br>insert all the data in @AoA=() into "ColumnB, Row2" or insert "fred" in B2,
<br>"barney" in B3, or others?<br><br>2007/1/30, <a href="mailto:china-pm-request@pm.org">china-pm-request@pm.org</a> <<a href="mailto:china-pm-request@pm.org">china-pm-request@pm.org</a>>:<br>><br>> Send China-pm mailing list submissions to
<br>> <a href="mailto:china-pm@pm.org">china-pm@pm.org</a><br>><br>> To subscribe or unsubscribe via the World Wide Web, visit<br>> <a href="http://mail.pm.org/mailman/listinfo/china-pm">http://mail.pm.org/mailman/listinfo/china-pm
</a><br>> or, via email, send a message with subject or body 'help' to<br>> <a href="mailto:china-pm-request@pm.org">china-pm-request@pm.org</a><br>><br>> You can reach the person managing the list at
<br>> <a href="mailto:china-pm-owner@pm.org">china-pm-owner@pm.org</a><br>><br>> When replying, please edit your Subject line so it is more specific<br>> than "Re: Contents of China-pm digest..."
<br>><br>><br>> Today's Topics:<br>><br>> 1. Want to get a module (Jeff Pang)<br>><br>><br>> ----------------------------------------------------------------------<br>><br>> Message: 1
<br>> Date: Mon, 29 Jan 2007 21:41:50 +0800 (GMT+08:00)<br>> From: Jeff Pang <<a href="mailto:pangj@earthlink.net">pangj@earthlink.net</a>><br>> Subject: [PerlChina] Want to get a module<br>> To: PerlList-China <
<a href="mailto:china-pm@pm.org">china-pm@pm.org</a>><br>> Message-ID:<br>> <<br>> <a href="mailto:14734423.1170078110884.JavaMail.root@elwamui-huard.atl.sa.earthlink.net">14734423.1170078110884.JavaMail.root@elwamui-huard.atl.sa.earthlink.net
</a>><br>><br>> Content-Type: text/plain; charset=UTF-8<br>><br>> Hello,<br>><br>> One of my friends asked the helps from me and hope I could write a Perl<br>> module for handling Excel file for him.
<br>><br>> He would like to call the module's function like this:<br>><br>> &export_to_excel($filename, $location, \@data_array);<br>><br>> $location is, for example, "B2",which means Column B, Row 2.
<br>> @data_array looks like:<br>> @AoA = (<br>> [ "fred", "barney" ],<br>> [ "george", "jane", "elroy" ],<br>> [ "homer", "marge", "bart" ],
<br>> );<br>><br>> I'm not familiar with Windows and Excel at all.So I ask the helps here.I'd<br>> like to pay RMB 100 for the function.<br>> I think if there is some a guy who is familiar with them,he could spend
<br>> about 1 hour to finish it.<br>> Anyone who is interested in it,please contact with me.<br>><br>> Thanks!<br>><br>><br>> --<br>> Books below translated by me to Chinese.<br>> Practical mod_perl:
<a href="http://home.earthlink.net/~pangj/mod_perl/">http://home.earthlink.net/~pangj/mod_perl/</a><br>> Squid the Definitive Guide: <a href="http://home.earthlink.net/~pangj/squid/">http://home.earthlink.net/~pangj/squid/
</a><br>><br>><br>> ------------------------------<br>><br>> _______________________________________________<br>> China-pm mailing list<br>> <a href="mailto:China-pm@pm.org">China-pm@pm.org</a><br>>
<a href="http://mail.pm.org/mailman/listinfo/china-pm">http://mail.pm.org/mailman/listinfo/china-pm</a><br>><br>> End of China-pm Digest, Vol 21, Issue 3<br>> ***************************************<br>><br><br>
<br><br>--<br>Best regards,<br><br>Jim Zhang<br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <a href="http://mail.pm.org/pipermail/china-pm/attachments/20070130/ae3480e7/attachment-0001.html">
http://mail.pm.org/pipermail/china-pm/attachments/20070130/ae3480e7/attachment-0001.html</a><br><br>------------------------------<br><br>Message: 2<br>Date: Tue, 30 Jan 2007 01:16:18 -0500 (EST)<br>From: Jeff Pang <<a href="mailto:pangj@earthlink.net">
pangj@earthlink.net</a>><br>Subject: Re: [PerlChina] China-pm Digest, Vol 21, Issue 3<br>To: <a href="mailto:china-pm@pm.org">china-pm@pm.org</a><br>Message-ID:<br> <<a href="mailto:23182906.1170137778963.JavaMail.root@elwamui-cypress.atl.sa.earthlink.net">
23182906.1170137778963.JavaMail.root@elwamui-cypress.atl.sa.earthlink.net</a>><br><br>Content-Type: text/plain; charset="utf-8"<br><br>An HTML attachment was scrubbed...<br>URL: <a href="http://mail.pm.org/pipermail/china-pm/attachments/20070130/321084f0/attachment-0001.html">
http://mail.pm.org/pipermail/china-pm/attachments/20070130/321084f0/attachment-0001.html</a><br><br>------------------------------<br><br>Message: 3<br>Date: Tue, 30 Jan 2007 15:19:44 +0800<br>From: Wan <<a href="mailto:wanmyome@gmail.com">
wanmyome@gmail.com</a>><br>Subject: Re: [PerlChina] Want to get a module<br>To: Jeff Pang <<a href="mailto:pangj@earthlink.net">pangj@earthlink.net</a>>, <a href="mailto:china-pm@pm.org">china-pm@pm.org</a><br>Message-ID: <
<a href="mailto:45BEF190.8000006@gmail.com">45BEF190.8000006@gmail.com</a>><br>Content-Type: text/plain; charset=UTF-8; format=flowed<br><br>#!/usr/bin/perl<br>use Win32::OLE;<br>my $ex = Win32::OLE->new('Excel.Application
') or die "oops\n";<br>#$ex->{Visible} = 1;<br>my $wb = $ex->Workbooks->Open("D:/new.xls");<br>my $sheet = $wb->Worksheets(1);<br>$sheet->cells(1,1)->{value} = "哈哈,不到10分钟就可以挣100块钱,幸福啊";
<br>$sheet->cells(2,1)->{value} = "不过这样拿你钱好像有点好像有点残忍";<br>$wb->Save;<br>$wb->Close;<br>$ex->Quit;<br><br>你在网上查一下Excel.Application<br><br><br>------------------------------<br><br>Message: 4<br>Date: Tue, 30 Jan 2007 02:54:06 -0500 (EST)
<br>From: Jeff Pang <<a href="mailto:pangj@earthlink.net">pangj@earthlink.net</a>><br>Subject: Re: [PerlChina] Want to get a module<br>To: Wan <<a href="mailto:wanmyome@gmail.com">wanmyome@gmail.com</a>>, <a href="mailto:china-pm@pm.org">
china-pm@pm.org</a><br>Message-ID:<br> <<a href="mailto:16700658.1170143646645.JavaMail.root@elwamui-cypress.atl.sa.earthlink.net">16700658.1170143646645.JavaMail.root@elwamui-cypress.atl.sa.earthlink.net</a>>
<br><br>Content-Type: text/plain; charset=UTF-8<br><br>Thanks.<br>他的目的是要能写一个已存在的excel文件,就是说某个excel文件已存在,他可以打开,并从指定位置($location)开始追加数据(@data)。你的这个函数能做到吗?能搞定我马上给你pay money.:)<br><br>-----Original Message-----<br>>From: Wan <
<a href="mailto:wanmyome@gmail.com">wanmyome@gmail.com</a>><br>>Sent: Jan 30, 2007 2:19 AM<br>>To: Jeff Pang <<a href="mailto:pangj@earthlink.net">pangj@earthlink.net</a>>, <a href="mailto:china-pm@pm.org">
china-pm@pm.org</a><br>>Subject: Re: [PerlChina] Want to get a module<br>><br>>#!/usr/bin/perl<br>>use Win32::OLE;<br>>my $ex = Win32::OLE->new('Excel.Application') or die "oops\n";<br>
>#$ex->{Visible} = 1;<br>>my $wb = $ex->Workbooks->Open("D:/new.xls");<br>>my $sheet = $wb->Worksheets(1);<br>>$sheet->cells(1,1)->{value} = "哈哈,不到10分钟就可以挣100块钱,幸福啊";<br>>$sheet->cells(2,1)->{value} = "不过这样拿你钱好像有点好像有点残忍";
<br>>$wb->Save;<br>>$wb->Close;<br>>$ex->Quit;<br>><br>>你在网上查一下Excel.Application<br><br><br>--<br>Books below translated by me to Chinese.<br>Practical mod_perl: <a href="http://home.earthlink.net/~pangj/mod_perl/">
http://home.earthlink.net/~pangj/mod_perl/</a><br>Squid the Definitive Guide: <a href="http://home.earthlink.net/~pangj/squid/">http://home.earthlink.net/~pangj/squid/</a><br><br><br>------------------------------<br><br>
Message: 5<br>Date: Tue, 30 Jan 2007 02:56:04 -0500 (EST)<br>From: Jeff Pang <<a href="mailto:pangj@earthlink.net">pangj@earthlink.net</a>><br>Subject: Re: [PerlChina] Want to get a module<br>To: <a href="mailto:china-pm@pm.org">
china-pm@pm.org</a><br>Message-ID:<br> <<a href="mailto:7733530.1170143764356.JavaMail.root@elwamui-cypress.atl.sa.earthlink.net">7733530.1170143764356.JavaMail.root@elwamui-cypress.atl.sa.earthlink.net</a>><br>
<br>Content-Type: text/plain; charset=UTF-8<br><br><br>另外,非常不好意思。他要求脚本在Linux上工作,呵呵。<br><br><br>-----Original Message-----<br>>From: Jeff Pang <<a href="mailto:pangj@earthlink.net">pangj@earthlink.net</a>><br>>Sent: Jan 30, 2007 2:54 AM
<br>>To: Wan <<a href="mailto:wanmyome@gmail.com">wanmyome@gmail.com</a>>, <a href="mailto:china-pm@pm.org">china-pm@pm.org</a><br>>Subject: Re: [PerlChina] Want to get a module<br>><br>>Thanks.<br>>他的目的是要能写一个已存在的excel文件,就是说某个excel文件已存在,他可以打开,并从指定位置($location)开始追加数据(@data)。你的这个函数能做到吗?能搞定我马上给你pay money.:)
<br>><br>>-----Original Message-----<br>>>From: Wan <<a href="mailto:wanmyome@gmail.com">wanmyome@gmail.com</a>><br>>>Sent: Jan 30, 2007 2:19 AM<br>>>To: Jeff Pang <<a href="mailto:pangj@earthlink.net">
pangj@earthlink.net</a>>, <a href="mailto:china-pm@pm.org">china-pm@pm.org</a><br>>>Subject: Re: [PerlChina] Want to get a module<br>>><br>>>#!/usr/bin/perl<br>>>use Win32::OLE;<br>>>my $ex = Win32::OLE->new('
Excel.Application') or die "oops\n";<br>>>#$ex->{Visible} = 1;<br>>>my $wb = $ex->Workbooks->Open("D:/new.xls");<br>>>my $sheet = $wb->Worksheets(1);<br>>>$sheet->cells(1,1)->{value} = "哈哈,不到10分钟就可以挣100块钱,幸福啊";
<br>>>$sheet->cells(2,1)->{value} = "不过这样拿你钱好像有点好像有点残忍";<br>>>$wb->Save;<br>>>$wb->Close;<br>>>$ex->Quit;<br>>><br>>>你在网上查一下Excel.Application<br>><br>><br>
>--<br>>Books below translated by me to Chinese.<br>>Practical mod_perl: <a href="http://home.earthlink.net/~pangj/mod_perl/">http://home.earthlink.net/~pangj/mod_perl/</a><br>>Squid the Definitive Guide: <a href="http://home.earthlink.net/~pangj/squid/">
http://home.earthlink.net/~pangj/squid/</a><br>>_______________________________________________<br>>China-pm mailing list<br>><a href="mailto:China-pm@pm.org">China-pm@pm.org</a><br>><a href="http://mail.pm.org/mailman/listinfo/china-pm">
http://mail.pm.org/mailman/listinfo/china-pm</a><br><br><br>--<br>Books below translated by me to Chinese.<br>Practical mod_perl: <a href="http://home.earthlink.net/~pangj/mod_perl/">http://home.earthlink.net/~pangj/mod_perl/
</a><br>Squid the Definitive Guide: <a href="http://home.earthlink.net/~pangj/squid/">http://home.earthlink.net/~pangj/squid/</a><br><br><br>------------------------------<br><br>Message: 6<br>Date: Tue, 30 Jan 2007 16:03:19 +0800
<br>From: "Dongxu Ma" <<a href="mailto:dongxu.ma@gmail.com">dongxu.ma@gmail.com</a>><br>Subject: Re: [PerlChina] Want to get a module<br>To: "Jeff Pang" <<a href="mailto:pangj@earthlink.net">pangj@earthlink.net
</a>>, <a href="mailto:china-pm@pm.org">china-pm@pm.org</a><br>Message-ID:<br> <<a href="mailto:9bc0d5d20701300003i7127c231md9a70762672648f4@mail.gmail.com">9bc0d5d20701300003i7127c231md9a70762672648f4@mail.gmail.com
</a>><br>Content-Type: text/plain; charset="gb2312"<br><br>Please _DO_ check CPAN<br><br><a href="http://search.cpan.org/~scesano/Spreadsheet-TieExcel-0.75/TieExcel.pod">http://search.cpan.org/~scesano/Spreadsheet-TieExcel-0.75/TieExcel.pod
</a><br><a href="http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.18/lib/Spreadsheet/WriteExcel.pm">http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.18/lib/Spreadsheet/WriteExcel.pm</a><br><a href="http://www-128.ibm.com/developerworks/library/l-pexcel/">
http://www-128.ibm.com/developerworks/library/l-pexcel/</a><br><br>On 1/30/07, Jeff Pang <<a href="mailto:pangj@earthlink.net">pangj@earthlink.net</a>> wrote:<br>><br>><br>> 另外,非常不好意思。他要求脚本在Linux上工作,呵呵。<br>
><br>><br>> -----Original Message-----<br>> >From: Jeff Pang <<a href="mailto:pangj@earthlink.net">pangj@earthlink.net</a>><br>> >Sent: Jan 30, 2007 2:54 AM<br>> >To: Wan <<a href="mailto:wanmyome@gmail.com">
wanmyome@gmail.com</a>>, <a href="mailto:china-pm@pm.org">china-pm@pm.org</a><br>> >Subject: Re: [PerlChina] Want to get a module<br>> ><br>> >Thanks.<br>> >他的目的是要能写一个已存在的excel文件,就是说某个excel文件已存在,他可以打开,并从指定位置($location)开始追加数据(@data)。你的这个函数能做到吗?能搞定我马上给你pay
<br>> money.:)<br>> ><br>> >-----Original Message-----<br>> >>From: Wan <<a href="mailto:wanmyome@gmail.com">wanmyome@gmail.com</a>><br>> >>Sent: Jan 30, 2007 2:19 AM<br>> >>To: Jeff Pang <
<a href="mailto:pangj@earthlink.net">pangj@earthlink.net</a>>, <a href="mailto:china-pm@pm.org">china-pm@pm.org</a><br>> >>Subject: Re: [PerlChina] Want to get a module<br>> >><br>> >>#!/usr/bin/perl
<br>> >>use Win32::OLE;<br>> >>my $ex = Win32::OLE->new('Excel.Application') or die "oops\n";<br>> >>#$ex->{Visible} = 1;<br>> >>my $wb = $ex->Workbooks->Open("D:/new.xls");
<br>> >>my $sheet = $wb->Worksheets(1);<br>> >>$sheet->cells(1,1)->{value} = "哈哈,不到10分钟就可以挣100块钱,幸福啊";<br>> >>$sheet->cells(2,1)->{value} = "不过这样拿你钱好像有点好像有点残忍";
<br>> >>$wb->Save;<br>> >>$wb->Close;<br>> >>$ex->Quit;<br>> >><br>> >>你在网上查一下Excel.Application<br>> ><br>> ><br>> >--<br>> >Books below translated by me to Chinese.
<br>> >Practical mod_perl: <a href="http://home.earthlink.net/~pangj/mod_perl/">http://home.earthlink.net/~pangj/mod_perl/</a><br>> >Squid the Definitive Guide: <a href="http://home.earthlink.net/~pangj/squid/">
http://home.earthlink.net/~pangj/squid/</a><br>> >_______________________________________________<br>> >China-pm mailing list<br>> ><a href="mailto:China-pm@pm.org">China-pm@pm.org</a><br>> ><a href="http://mail.pm.org/mailman/listinfo/china-pm">
http://mail.pm.org/mailman/listinfo/china-pm</a><br>><br>><br>> --<br>> Books below translated by me to Chinese.<br>> Practical mod_perl: <a href="http://home.earthlink.net/~pangj/mod_perl/">http://home.earthlink.net/~pangj/mod_perl/
</a><br>> Squid the Definitive Guide: <a href="http://home.earthlink.net/~pangj/squid/">http://home.earthlink.net/~pangj/squid/</a><br>> _______________________________________________<br>> China-pm mailing list<br>
> <a href="mailto:China-pm@pm.org">China-pm@pm.org</a><br>> <a href="http://mail.pm.org/mailman/listinfo/china-pm">http://mail.pm.org/mailman/listinfo/china-pm</a><br><br><br><br><br>--<br>Cheers, Dongxu<br>__END__<br>
<a href="http://search.cpan.org/~dongxu">http://search.cpan.org/~dongxu</a><br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <a href="http://mail.pm.org/pipermail/china-pm/attachments/20070130/fd49e24e/attachment.html">
http://mail.pm.org/pipermail/china-pm/attachments/20070130/fd49e24e/attachment.html</a><br><br>------------------------------<br><br>_______________________________________________<br>China-pm mailing list<br><a href="mailto:China-pm@pm.org">
China-pm@pm.org</a><br><a href="http://mail.pm.org/mailman/listinfo/china-pm">http://mail.pm.org/mailman/listinfo/china-pm</a><br><br>End of China-pm Digest, Vol 21, Issue 4<br>***************************************<br></blockquote>
</div><br><br clear="all"><br>-- <br>Best regards,<br><br>Jim Zhang