可以参考:  http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel/lib/Spreadsheet/WriteExcel.pm

  1. 使用Spreadsheet::WriteExcel这个模块,如果能很好的使用这个模块,从perl输出到excel的操作也就没什么问题了。利用它的几个函数,就可以方便地把数据写入到Excel相应的位置中,同时还可以设置单元格的格式,如字体大小,单元格大小,是否加粗,底色等等。这一篇为基础篇.
  2. 通过命令:perldoc perllocal来查看环境中装了perl的哪些模块,看看是否有这个模块。
  3. 用perl创建excel表格
     
    #!/usr/bin/perl 
    use strict; 
    use Spreadsheet::WriteExcel;  
    #************生成Excel文档****************  
    my $xl = Spreadsheet::WriteExcel->new("TEST.xls");  #引号中为生成的excel的名称,瘦箭头后面都是模块Spreadsheet::WriteExcel中的方面。
    #生成Excel表  
    my $xlsheet = $xl->add_worksheet("TestSheet");  #引号中为excel工作簿中表的名称
    $xlsheet->freeze_panes(1, 0); #冻结首行
  4. 输出的格式设置

    #添加格式(表头)
    my $rptheader = $xl->add_format(); # Add a format
    $rptheader->set_bold(); #加粗
    $rptheader->set_size('18'); #字体大小
    $rptheader->set_align('center'); #居中
    $rptheader->set_font('BrowalliaUPC'); #字体
    #添加格式(表内容)
    my $normcell = $xl->add_format(); # Add a format
    $normcell->set_size('11');
    $normcell->set_align('center');
    $normcell->set_bg_color('21'); #背景色
    #设置列的宽度
    $xlsheet->set_column('A:A',12);
    $xlsheet->set_column('B:B',10);
    $xlsheet->set_column('C:C',14);
     
  5. 输出
    1. #写表头(格式是使用上面添加的表头格式) 
      $xlsheet->write("A1","Number", $rptheader); #格式为(单元格位置,写入的内容,格式)
      $xlsheet->write("B1","Name",$rptheader);
      $xlsheet->write("C1","Language",$rptheader);
      #写内容(格式是使用上面添加的表内容格式)
      $xlsheet->write("A2","1", $normcell);
      $xlsheet->write("B2","Test",$normcell);
      $xlsheet->write("C2","Perl",$normcell);
      #关闭操作excel的对象.
      $xl->close();

Perl 输出内容到 excel的更多相关文章

  1. tail -f 实时跟踪一个日志文件的输出内容

    tail -f  实时跟踪一个日志文件的输出内容 http://hittyt.iteye.com/blog/1927026 https://blog.csdn.net/mengxianhua/arti ...

  2. C#获取命令行输出内容的方法

    获取命令行输出内容的方式有传统和异步两种方式. 传统方式: public static void RunExe(string exePath, string arguments, out string ...

  3. 【记录】尝试用android-logging-log4j去实现log输出内容到sd卡中的文件的功能

    [背景] 折腾: [记录]给Android中添加log日志输出到文件 期间,已经试了: [记录]尝试用android中microlog4android实现log输出到文件的功能 但是不好用. 然后就是 ...

  4. WinForm小白的WPF初试一:从PropertyGrid控件,输出内容到Word(上)

    学WinForm也就半年,然后转到WPF,还在熟悉中.最近拿到一个任务:从PropertyGrid控件,输出内容到Word.难点有: 一.PropertyGrid控件是WinForm控件,在WPF中并 ...

  5. Linux鲜为人知的安全漏洞:不要将输出内容管道给你的shell

    将wget或curl输出的内容管道给bash或者sh是一件非常愚蠢的事,例如像下面这样: wget -O - http://example.com/install.sh | sudo sh 命令解释: ...

  6. level分层次输出内容添加leve

    代码如下:function getSubComments($parent = 0, $level = 0) { $db = &JFactory::getDBO(); $sql = " ...

  7. paip.输出内容替换在Apache 过滤器filter的设置

    paip.输出内容替换在Apache 过滤器filter的设置 作者Attilax  艾龙,  EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog ...

  8. 输出内容(document.write)四种写法

    第一种:输出内容用""括起,直接输出""号内的内容 <script type="text/javascript"> docume ...

  9. 输出内容(document.write)

    document.write() 直接在页面中输出内容 第一种 直接输出 document.write("I Love Javascript !") //输出内容为:I Love ...

随机推荐

  1. view-source协议

    转自;https://blog.csdn.net/yuwq123/article/details/79481829

  2. C杂谈

    最近在做关于C的项目开发,记录一下有关C的操作,比较杂乱 1.利用System进行文件数量统计: 1) system("dir /b /s /ad d:\\mydir\\*.* | find ...

  3. humans.txt学习理解

    可以通过以下链接访问到Google的humans.txt https://www.google.com/humans.txt 百度上有关于humans.txt的介绍 http://baike.baid ...

  4. 支持lua的框架和ide

    1.Kony http://mobilehub.io/products/kony 2.CryEngine http://mobilehub.io/products/cryengine 3.Dragon ...

  5. Swift3.0 键盘高度监听获取

    方法:通过通知监听键盘的动态 1.键盘的动态有四种: public static let UIKeyboardWillShow: NSNotification.Name public static l ...

  6. PhpStorm插件之CodeGlance

    安装插件 File->Setting->Pluugins   搜索  CodeGlance 如何使用 安装完插件后,RESTART IDE,随便打开一个文件都可看到效果

  7. 无法打开包括文件:“SDKDDKVer.h”: No such file or directory

    在已经装有Visual Studio 2010的系统中,同时安装Visual Studio 2012,安装过程很顺利,但到使用VS2013时,却出问题了. 本文主要介绍:VS中新建工程编译时出现,“无 ...

  8. Mecanim Control

    http://www.ufe3d.com/doku.php/mecanimcontrol Mecanim Control Your ultimate solution for Mecanim base ...

  9. Unity 2D骨骼动画2:创建真实动画

    http://bbs.9ria.com/thread-401781-1-1.html 在这个系列,我们将关注Unity引擎提供的基于骨骼动画工具.它的主要思想是为了把它应用到你自己的游戏来介绍和教基本 ...

  10. Python decorate 函数

    1. decorate 函数需要在 "@wrap" 之前定义, 否则会报错