| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> perl >> yong Perl de WriteExcel cong shu ju ku sheng cheng dian zi shu ju biao ge wen jian

yong Perl de WriteExcel cong shu ju ku sheng cheng dian zi shu ju biao ge wen jian

2008-05-19 08:57:42 编辑來源:互联网 评论
 
 
 
本文为【用Perl的WriteExcel从数据库生成电子数据表格文件】的拼音翻译版
  xu duo shang ye zui zhong yong hu geng xi huan shi yong mu qian liu xing de dian zi shu ju biao ge cheng xu ( ru Microsoft Excel), er bu shi shu ju ku gong neng huo ying yong cheng xu 。 jin guan Excel ke yi yong ODBC ji xiang guan ji shu lai ti qu chu cun zai Oracle shu ju ku dang zhong de shu ju , dan xiang rang yong hu jian li yi ge huan jing lai zhi jie fang wen shu ju huo shi tong guo an zhuang jiao ben lai an zhuang shu ju zi yuan ke neng hui bu da he li 。
  yin ci , dui yu cheng xu kai fa ren yuan lai shuo , cong chu cun zai shu ju ku zhong de shu ju sheng cheng yi ge dian zi shu ju biao ge , bing tong guo e-mail huo wang zhan jiang qi wen dang chuan hui yong hu shou zhong , shi yi ge fei chang ji ben de yi ban yao qiu 。
  guan yu ru he sheng cheng Excel dian zi shu ju biao ge , yi ge dian xing hui da shi , sheng cheng yi ge CSV(comma-separated values) wen jian , zai zhe li mei yi ge zi duan dou yong yi ge Text shu xing lai shuo ming , ke neng bao han zai yin hao li 。 zhe zhong qing kuang xia , zhe ge wen jian zuo wei yuan shi shu ju bei zhong duan yong hu jie shou , zhong duan yong hu zai Excel xia da kai ta , tong guo yi ge dui hua jiang shu ju zheng que de fen jie cheng dian zi shu ju biao ge zhong de dan yuan ge 。
  ye ke neng jin jin tong guo chuan song zuo wei yi ge dian zi shu ju biao ge shu xing de gong shi ( ru “=A1+B1”), jiang zhe xie gong shi xie jin dian zi shu ju biao ge , er zhe ge gong shi zhi you zai zi duan bei zhun que du qu dao zheng que wei zhi shi cai hui you yong 。 zai zhe zhong qing kuang xia , mei you ge shi hua kong zhi , dang shu ju du ru shi , zui zhong yong hu zhi neng shou gong jiang yi ge dian zi shu ju biao ge chong xin ge shi hua 。
  yi ge Perl ti dai pin
  xian zai you le yi ge fei chang you yong de CSV wen jian de ti dai pin 。John McNamara chuang jian le yi ge Perl mo kuai , jiao zuo Spreadsheet::WriteExcel, ta neng dong tai sheng cheng yi ge zhen zheng de 、 er jin zhi de 、Excel de dian zi shu ju biao ge wen jian 。
  zai zhe ge mo kuai zhong , ni ke yi chuang jian yi ge gong zuo shou ce , bing zai qi zhong jia ru gong zuo biao , ran hou zhi jie xie ru gong zuo biao dan yuan ge 。 you xu duo ge shi hua xuan xiang yuan xu ni gai bian zi duan shu ju de ge shi 、 hei ti 、 dui qi fang shi 、 zi ti 、 qian jing he bei jing yan se 、 tian chong tu an yi ji bian kuang 。
  ling wai ,Spreadsheet::WriteExcel ke yi gai bian zi ti , wen zi bian xing he xuan zhuan wen zi , cha ru wei tu , she zhi mi ma bao hu gong zuo biao , yi ji jian li neng yong shu biao kuo zhan de shu ju ji he 。 dang ran huan neng gou she zhi da yin xuan xiang he ye mian zan ting de gong neng 。
  gai mo kuai huan ke yi xie biao zhun shu chu shu ju , yin ci ta ke yi zai cgi-bin cheng xu zhong shi yong 。 qi ta cheng xu yu yan ke yi tong guo HTTP URL shen zhao cgi-bin, lai qing qiu Excel dian zi shu ju biao ge dian zi shu ju biao ge 。
  xia mian shi yi ge li zi , ta yong DBI cong EMP biao zhong ti qu shu ju bing yong gong shi he ge shi hua sheng cheng yi ge Excel dian zi shu ju biao ge dian zi shu ju biao ge 。
  use DBI;
  use Spreadsheet::WriteExcel;
  # connect to the local database
  my $dbh = DBI-connect('dbi:Oracle:','scott','tiger') || die $DBI::errstr;
  print "Generating Excel Spreadsheet\n";
  my $workbook = new Spreadsheet::WriteExcel "emp.xls";
  my $worksheet = $workbook-add_worksheet();
  my $fmt = {
  HEADER = $workbook-add_format(bold=1,align='center',
  bottom=2,bg_color='silver'),
  ENAME = $workbook-add_format(bold=1,color='blue'),
  MONEY = $workbook-add_format(
  num_format='$#,##0.00',align='right'),
  TOTAL = $workbook-add_format(
  num_format='$#,##0.00',align='right',bold=1,
  top=2),
  };
  print "Querying Employees\n";
  my $sth = $dbh-prepare('select * from emp') || die $DBI::errstr;
  my $rc = $sth-execute;
  my $r = 1;
  $worksheet-write($r-1,0,'Employee',$fmt-{HEADER});
  $worksheet-write($r-1,1,'Salary',$fmt-{HEADER});
  $worksheet-write($r-1,2,'Commission',$fmt-{HEADER});
  $worksheet-write($r-1,3,'Total',$fmt-{HEADER});
  $r++;
  while (my $row = $sth-fetchrow_hashref)
  {
  $worksheet-write($r-1,0,$row-{ENAME},$fmt-{ENAME});
  $worksheet-write($r-1,1,$row-{SAL},$fmt-{MONEY});
  $worksheet-write($r-1,2,$row-{COMM},$fmt-{MONEY});
  $worksheet-write($r-1,3,"=B$r+C$r",$fmt-{MONEY});
  $r++;
  }
  $worksheet-write($r-1,0,'',$fmt-{TOTAL});
  $worksheet-write($r-1,1,'=SUM(B2:B'.($r-1).')',$fmt-{TOTAL});
  $worksheet-write($r-1,2,'=SUM(C2:C'.($r-1).')',$fmt-{TOTAL});
  $worksheet-write($r-1,3,"=B$r+C$r",$fmt-{TOTAL});
  print "Processed " . ($r-2) ." rows\n";
  $sth-finish;
  【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
   xu duo shang ye zui zhong yong hu geng xi huan shi yong mu qian liu xing de dian zi shu ju biao ge cheng xu ( ru Microsoft Excel), er bu shi shu ju ku gong neng huo ying yong cheng xu 。 jin guan Excel ke yi yong ODBC ji xiang guan ji shu lai ti qu chu cun zai Oracle shu ju ku dang zhong de shu ju , dan xiang rang yong hu jian li yi ge huan jing lai zhi jie fang wen shu ju huo shi tong guo an zhuang jiao ben lai an zhuang shu ju zi yuan ke neng hui bu da he li 。    yin ci , dui yu cheng xu kai fa ren yuan lai shuo , cong chu cun zai shu ju ku zhong de shu ju sheng cheng yi ge dian zi shu ju biao ge , bing tong guo e-mail huo wang zhan jiang qi wen dang chuan hui yong hu shou zhong , shi yi ge fei chang ji ben de yi ban yao qiu 。    guan yu ru he sheng cheng Excel dian zi shu ju biao ge , yi ge dian xing hui da shi , sheng cheng yi ge CSV(comma-separated values) wen jian , zai zhe li mei yi ge zi duan dou yong yi ge Text shu xing lai shuo ming , ke neng bao han zai yin hao li 。 zhe zhong qing kuang xia , zhe ge wen jian zuo wei yuan shi shu ju bei zhong duan yong hu jie shou , zhong duan yong hu zai Excel xia da kai ta , tong guo yi ge dui hua jiang shu ju zheng que de fen jie cheng dian zi shu ju biao ge zhong de dan yuan ge 。    ye ke neng jin jin tong guo chuan song zuo wei yi ge dian zi shu ju biao ge shu xing de gong shi ( ru “=A1+B1”), jiang zhe xie gong shi xie jin dian zi shu ju biao ge , er zhe ge gong shi zhi you zai zi duan bei zhun que du qu dao zheng que wei zhi shi cai hui you yong 。 zai zhe zhong qing kuang xia , mei you ge shi hua kong zhi , dang shu ju du ru shi , zui zhong yong hu zhi neng shou gong jiang yi ge dian zi shu ju biao ge chong xin ge shi hua 。    yi ge Perl ti dai pin    xian zai you le yi ge fei chang you yong de CSV wen jian de ti dai pin 。John McNamara chuang jian le yi ge Perl mo kuai , jiao zuo Spreadsheet::WriteExcel, ta neng dong tai sheng cheng yi ge zhen zheng de 、 er jin zhi de 、Excel de dian zi shu ju biao ge wen jian 。    zai zhe ge mo kuai zhong , ni ke yi chuang jian yi ge gong zuo shou ce , bing zai qi zhong jia ru gong zuo biao , ran hou zhi jie xie ru gong zuo biao dan yuan ge 。 you xu duo ge shi hua xuan xiang yuan xu ni gai bian zi duan shu ju de ge shi 、 hei ti 、 dui qi fang shi 、 zi ti 、 qian jing he bei jing yan se 、 tian chong tu an yi ji bian kuang 。    ling wai ,Spreadsheet::WriteExcel ke yi gai bian zi ti , wen zi bian xing he xuan zhuan wen zi , cha ru wei tu , she zhi mi ma bao hu gong zuo biao , yi ji jian li neng yong shu biao kuo zhan de shu ju ji he 。 dang ran huan neng gou she zhi da yin xuan xiang he ye mian zan ting de gong neng 。    gai mo kuai huan ke yi xie biao zhun shu chu shu ju , yin ci ta ke yi zai cgi-bin cheng xu zhong shi yong 。 qi ta cheng xu yu yan ke yi tong guo HTTP URL shen zhao cgi-bin, lai qing qiu Excel dian zi shu ju biao ge dian zi shu ju biao ge 。    xia mian shi yi ge li zi , ta yong DBI cong EMP biao zhong ti qu shu ju bing yong gong shi he ge shi hua sheng cheng yi ge Excel dian zi shu ju biao ge dian zi shu ju biao ge 。   use DBI;   use Spreadsheet::WriteExcel;   # connect to the local database   my $dbh = DBI-connect('dbi:Oracle:','scott','tiger') || die $DBI::errstr;   print "Generating Excel Spreadsheet\n";   my $workbook = new Spreadsheet::WriteExcel "emp.xls";   my $worksheet = $workbook-add_worksheet();   my $fmt = {   HEADER = $workbook-add_format(bold=1,align='center',   bottom=2,bg_color='silver'),   ENAME = $workbook-add_format(bold=1,color='blue'),   MONEY = $workbook-add_format(   num_format='$#,##0.00',align='right'),   TOTAL = $workbook-add_format(   num_format='$#,##0.00',align='right',bold=1,   top=2),   };   print "Querying Employees\n";   my $sth = $dbh-prepare('select * from emp') || die $DBI::errstr;   my $rc = $sth-execute;   my $r = 1;   $worksheet-write($r-1,0,'Employee',$fmt-{HEADER});   $worksheet-write($r-1,1,'Salary',$fmt-{HEADER});   $worksheet-write($r-1,2,'Commission',$fmt-{HEADER});   $worksheet-write($r-1,3,'Total',$fmt-{HEADER});   $r++;   while (my $row = $sth-fetchrow_hashref)   {   $worksheet-write($r-1,0,$row-{ENAME},$fmt-{ENAME});   $worksheet-write($r-1,1,$row-{SAL},$fmt-{MONEY});   $worksheet-write($r-1,2,$row-{COMM},$fmt-{MONEY});   $worksheet-write($r-1,3,"=B$r+C$r",$fmt-{MONEY});   $r++;   }   $worksheet-write($r-1,0,'',$fmt-{TOTAL});   $worksheet-write($r-1,1,'=SUM(B2:B'.($r-1).')',$fmt-{TOTAL});   $worksheet-write($r-1,2,'=SUM(C2:C'.($r-1).')',$fmt-{TOTAL});   $worksheet-write($r-1,3,"=B$r+C$r",$fmt-{TOTAL});   print "Processed " . ($r-2) ." rows\n";   $sth-finish;   
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
时尚秀气模特裴裴(8)
时尚秀气模特裴裴(7)
时尚秀气模特裴裴(6)
时尚秀气模特裴裴(5)
白墙黑瓦
广州东郊[原创]
八美至丹巴的东谷天然盆景
不一样的
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有