您的位置:首页 > 其它

Spreadsheet电子表格控件安装及用法总结

2014-10-27 17:40 661 查看
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/20052Spreadsheet::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就行了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: