打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Spreadsheet电子表格控件安装及用法总结
Spreadsheet是一个用来查看和编辑Excel电子表格文件的控件,它可用在类似Excel的界面上。它结合了很多我们最流行的部件,像网格控件,Ribbon组件,公式引擎,还有很多其他控件。旨在创建一款和Silverlight同类的控件,可以查看和编辑Excel文件。

  在Windows上安装ActivePerl所需要的读取在线Excel文件一般用Win32::OLE,但对于跨平台来说,还是选择另外的 Spreadsheet::ParseExcel及Spreadsheet::WriteExcel最好。前者是读Excel文件用的,后者用于写Excel文件。

Spreadsheet::ParseExcel只能读95-2003格式的Excel文档,对于office 2007 Excel则要安装Spreadsheet::XLSX。

Spreadsheet安装

Windows下安装

ppm> install OLE::Storage_Lite

ppm> install Spreadsheet::ParseExcel

ppm> install Spreadsheet::WriteExcel

Mac下安装

sudo perl -MCPAN -e "install 'Spreadsheet::ParseExcel'"

Spreadsheet插入行/列

在owc提供的Spreadsheet api 中,没有直接添加行列的方法,可以使用执行命令的方式实现

添加新行在第3行,代码如下:

   var ssConstants = Spreadsheet1.Constants;
   Spreadsheet1.ActiveSheet.Row(3).Select();
   Spreadsheet1.Commands(ssConstants.ssCommandInsertRows).Execute();
添加新列在第3列,代码如下:
   var ssConstants = Spreadsheet1.Constants;
   Spreadsheet1.ActiveSheet.cells(2,3).Select();

   Spreadsheet1.Commands(ssConstants.ssCommandInsertCols).Execute();

原文来自:http://www.6excel.com/doc/20052
Spreadsheet::WriteExcel

#usr/bin/perl -w
 use strict;
use Spreadsheet::WriteExcel;
  
my $workbook = Spreadsheet::WriteExcel -> new('perl.xls');
my $worksheet = $workbook -> add_worksheet('sheetname1');
$worksheet -> write("A1","Hello word!");


Format的函数库

   $contentStyle->set_size( 8 );
    $contentStyle->set_bold(); #设置字体为粗体
    $contentStyle->set_align( 'center' );#设置单元格居中
    $contentStyle->set_text_wrap(); #是否回车换行
    $contentStyle->set_color('red'); #设置单元格前景色为红色
f_row = workbook.add_format(:color=>"black", :bold=>0, :italic=>false, :text_wrap=>true)
SpreadSheet是支持单元格合并的, http://rubyforge.org/forum/message.php?msg_id=64873
  把要合并的单元格的格式属性设置为:align => :merge就行了
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
办公软件使用——Excel电子表格的使用技巧
电子表格EXCEL【下】
电子表格EXCEL(下)
全面认识Excel 电子表格
Excel 2003电子表格系统的基本操作
Office电子表格经典教程
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服