NAME
Mojolicious::Plugin::ExportExcel - The great new Mojolicious::Plugin::ExportExcel!
VERSION
Version 0.01
SYNOPSIS
# Mojolicious
$self->plugin('ExportExcel');
# Mojolicious::Lite
plugin 'ExportExcel';
EXPORT
A list of functions that can be exported. You can delete this section if you don't export anything, such as for a purely object-oriented module.
METHODS
Mojolicious::Plugin::ExportExcel 覆盖了Mojolicious::Pluginä¸çš„register方法。
register
å�‘Mojoliciousçš„rendererä¸æ·»åŠ 了一个handler:xls,用于渲染Excel文件。 å�‘Mojoliciousä¸æ·»åŠ 一个helper:render_excel,用于渲染Excel文件。
export_excel_renderer
执行xls handler时的渲染方法。
PARAMETER
option
my $option = [
{
key => "recharge_status", ## 从 data的当å‰�hashä¸å�–哪个键的值放入对应å�•å…ƒæ ¼
header => "状�", ## 对应列的表头
map => { ## 需è¦�对用key从dataå�–出的当å‰�值å�šæ˜ 射转æ�¢çš„规则
0 => "待支付",
2 => "待付款",
3 => "完�",
4 => "�消"
},
action=>sub{ ## action 与 map �有一个工作,且map优先级高
## 接收两个�数,
## 第一个为 当å‰�å�•å…ƒæ ¼çš„值
## 第二个为 当�行的hash对象
## 返回的值会被作为当å‰�å�•å…ƒæ ¼çš„最值写入excel表ä¸
## 其实功能与 map 类似
}
type=>"string", ## 数�类型,string,number,url
format=>{}, ## å¯¹åº”åˆ—çš„æ ·å¼�
},
……
];
settings
一个å˜å‚¨äº†excelè¡¨æ ¼é…�置信æ�¯çš„ hashref。
my $settings=>{
sheet_name => "", ## è¡¨æ ¼å��称 默认为空
header_format => {}, ## è¡¨å¤´æ ¼å¼� é»˜è®¤ä¸ºåŠ ç²—
data_format => {}, ## æ•°æ�®æ ¼å¼� é»˜è®¤ä¸ºæ— æ ¼å¼�
header_height => {}, ## 表头高度 默认为20
data_height => {}, ## 数�高度 默认为20
condition_format=>{ ## æ ¹æ�®æ�¡ä»¶è®¾ç½®æ ·å¼�
row=>[ ## æ ¹æ�®æ�¡ä»¶è®¾ç½®ä¸€è¡Œçš„æ ¼å¼�
{
key=>"", ## è¦�判æ–çš„æ•°æ�®è¡Œ
condition=>sub{}, ## 判æ–æ�¡ä»¶
format=>{} ## 满足æ�¡ä»¶æ—¶çš„æ ·å¼�
},
……
],
cell=>{ ## æ ¹æ�®æ�¡ä»¶è®¾ç½®ä¸€ä¸ªå�•å…ƒæ ¼çš„æ ·å¼�
key=>{ ## key è¦�判æ–æ•°æ�®çš„é”®å��
condition=>sub{}, ## 判æ–æ�¡ä»¶
format=>{} ## 满足æ�¡ä»¶æ—¶çš„æ ·å¼�
},
……
}
},
‘A:A'=>100 ## 对应列的宽度
}
data
一个hashref çš„ arrayref ,其ä¸å˜å‚¨çš„是è¦�渲染æˆ�excelè¡¨æ ¼çš„æ•°æ�®ã€‚
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Mojolicious::Plugin::ExportExcel
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 200:
Non-ASCII character seen before =encoding in '覆盖了Mojolicious::Pluginä¸çš„register方法。'. Assuming CP1252