国产chinesehdxxxx野外,国产av无码专区亚洲av琪琪,播放男人添女人下边视频,成人国产精品一区二区免费看,chinese丰满人妻videos

14.BDF2-EXPORT

2023-07-03 17:36 更新

功能介紹

bdf2-export模塊主要提供了對(duì)Dorado7中Datagrid和Autoform兩種類型的控件報(bào)表導(dǎo)出功能,以Datagrid或者Autoform為顯示模板,導(dǎo)出其數(shù)據(jù)為PDF或者Excel格式,支持Datagrid控件中filterBar數(shù)據(jù)過濾導(dǎo)出、列頭組合自定義、數(shù)據(jù)自定義導(dǎo)出等功能。同時(shí)可以利用BDF2中提供的swf-viewer模塊,在線瀏覽產(chǎn)生的報(bào)表文件,供用戶在線瀏覽和打印使用。

環(huán)境配置

  • Maven Project (推薦)
如果您采用Maven管理項(xiàng)目,可以通過訪問在線創(chuàng)建BDF2項(xiàng)目向?qū)В谀K選擇中勾選bdf2-export模塊,動(dòng)態(tài)創(chuàng)建一個(gè)MavenProject即可?;蛘咴诂F(xiàn)有的BDF2Maven項(xiàng)目中,將bdf2-export模塊的依賴信息添加到pom.xml文件當(dāng)中,依賴配置如下:
bdf2-export依賴信息
<dependency>
 <groupId>com.bstek.bdf2</groupId>
 <artifactId>bdf2-export</artifactId>
 <version>2.0.0</version>
</dependency>
  • Dynamic Web Project
如果您打算采用Dynamic Web Project方式,那么訪問在線創(chuàng)建BDF2項(xiàng)目向?qū)?,在?xiàng)目類型中選擇Dynamic Web Project,在模塊選擇中勾選bdf2-export模塊,動(dòng)態(tài)創(chuàng)建一個(gè)Dynamic Web Project即可,在這個(gè)動(dòng)態(tài)創(chuàng)建的項(xiàng)目中包含了bdf2-export模塊的jar包和第三方依賴包。
由于bdf2-export模塊采用Dorado7組件方式實(shí)現(xiàn)導(dǎo)出、預(yù)覽功能,那么在創(chuàng)建配置完成項(xiàng)目后,需要啟動(dòng)項(xiàng)目工程更新Dorado7配置規(guī)則(在線更新),更新完Dorado7配置規(guī)則后,打開DoradoView文件,可以看到在Dorado7工具欄新添加了一個(gè)組件Export2ReportAction。如下圖所示:

Export2ReportAction控件
Export2ReportAction控件提供了若干屬性配置,其中關(guān)鍵屬性如下表所示:
屬性名
類型
默認(rèn)值
描述
templateString
導(dǎo)出數(shù)據(jù)模板DataGrid或者AutoForm的控件id,如果有多個(gè)值那么逗號(hào)分隔,例如 autoForm1,dataGrid1
interceptorNameString服務(wù)端數(shù)據(jù)攔截器名稱
rowSpace
int
1報(bào)表間距,template屬性指定多個(gè)控件id時(shí)有效
autoDownloadbooleantrue是否自動(dòng)下載
showTitlebooleanfalse是否顯示標(biāo)題
titleNameString標(biāo)題的名稱
titleBgColorString#FFFFFF標(biāo)題背景色
titleFontColorString#000000標(biāo)題顏色
titleFontSizeint18標(biāo)題字體大小
showPageNumberbooleantrue是否顯示頁號(hào),導(dǎo)出pdf格式時(shí)有效
headerBgColorString#D8D8D8表頭背景色
headerFontColorString#000000表頭顏色
headerFontSizeint10表頭字體大小
dataBgColorString#FFFFFF數(shù)據(jù)背景色
dataFontColorString#000000數(shù)據(jù)顏色
dataFontSizeint10數(shù)據(jù)字體大小
dataScopeStringcurrentPage數(shù)據(jù)范圍,可選值currentPage、serverAll
maxSizeint1000導(dǎo)出數(shù)據(jù)最大記錄數(shù)
fileNameString導(dǎo)出報(bào)表文件名稱
extensionStringxls導(dǎo)出報(bào)表類型,可選值xls、xlsx、pdf,如果導(dǎo)出的excel數(shù)據(jù)量比較大,建議配置成xlsx格式
除了以上關(guān)鍵屬性外,Export2ReportAction還提供一個(gè)關(guān)鍵事件,可以利用此事件自定義客戶端數(shù)據(jù)的導(dǎo)出,如下表所示,
事件名稱事件描述
onGetExportData(self,arg)
客戶端獲取導(dǎo)出的數(shù)據(jù)時(shí)觸發(fā),
arg.id 導(dǎo)出模板控件id
arg.data 導(dǎo)出的數(shù)據(jù)

功能演示

  • 導(dǎo)出DataGrid
如下圖所示,對(duì)DataGrid控件數(shù)據(jù)做服務(wù)端導(dǎo)出,其中dataGrid控件id為dataGrid1:

在view上添加Export2ReportAction控件,設(shè)置其屬性template為dataGrid1,dataScope為serverAll,showTitle為true,titleName為注冊(cè)用戶,導(dǎo)出效果如下:

默認(rèn)導(dǎo)出是excel文件,如果設(shè)置屬性extension為pdf,則導(dǎo)出的是pdf文件,導(dǎo)出pdf效果如下:
如果設(shè)置屬性template為多個(gè)DataGrid控件id,并以逗號(hào)分隔表示,則可以導(dǎo)出多張表格數(shù)據(jù) ,導(dǎo)出的excel文件效果如下圖所示:
導(dǎo)出的pdf文件效果如下圖所示:
  • 導(dǎo)出AutoForm
如下圖所示,對(duì)AutoForm控件數(shù)據(jù)做導(dǎo)出,其中AutoForm控件id為autoForm1:
在Export2ReportAction控件上設(shè)置其屬性template為autoForm1 ,則默認(rèn)的導(dǎo)出效果如下圖所示:
如果設(shè)置屬性extension為pdf,導(dǎo)出pdf效果如下:

  • 在線預(yù)覽
在線預(yù)覽打印用到bdf2-swfviewe模塊,相關(guān)配置可參考16.BDF2-SWFVIEWER
在view中添加一個(gè)dialog控件,設(shè)置id屬性為dialogSwfViewer,在dialog上添加一個(gè)swfViewer控件,設(shè)置id屬性為swfViewerTest,寬度和高度分別為100%,調(diào)用代碼如下所示:
var action=view.get("#export2ReportAction1");
var dialog=view.get("#dialogSwfViewer");
//在服務(wù)端生成文件
action.set("autoDownload",false);
//文件類型為pdf
action.set("extension","pdf");
action.execute(function(result){
 dialog.show();
 var swfViewer=view.get("#swfViewerTest");
 //result包含文件id和name信息
 swfViewer.set("parameter",result);
 //export.pdf2swf 為內(nèi)置的處理器
 swfViewer.set("handlerName","export.pdf2swf");
 swfViewer.refreshSwf();
});
在線預(yù)覽效果如下圖所示:
  • 客戶端數(shù)據(jù)自定義攔截
設(shè)置屬性dataScope為currentPage,在事件onGetExportData上定義待導(dǎo)出的excel數(shù)據(jù),例如導(dǎo)出DataGrid中用戶勾選的數(shù)據(jù),代碼如下所示:
var grid=view.id(arg.id);
if(grid instanceof dorado.widget.DataGrid){
 //獲取表格中勾選的數(shù)據(jù)
 arg.data=grid.get("selection");
}
  • 服務(wù)端數(shù)據(jù)自定義攔截
如果需要對(duì)服務(wù)端導(dǎo)出的數(shù)據(jù)做攔截,則需要寫一個(gè)實(shí)現(xiàn)com.bstek.bdf2.export.interceptor.IDataInterceptor接口的類,并配置的spring上下文環(huán)境中,然后指定Export2ReportAction控件的屬性interceptorName值為實(shí)現(xiàn)類中g(shù)etName()方法返回的名稱。

例如對(duì)上面示例中的DataGrid控件列“是否是管理員”、“是否可用”做中文格式化處理,同時(shí)動(dòng)態(tài)在服務(wù)端添加一條導(dǎo)出記錄,則實(shí)現(xiàn)類定義如下所示:
package com.test;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Component;
import com.bstek.bdf2.export.interceptor.IDataInterceptor;
@Component
public class UserReportDataInterceptor implements IDataInterceptor {
 public String getName() {
 return "userReportDataInterceptor";
 }
 public String getDesc() {
 return "服務(wù)端表格數(shù)據(jù)攔截自定義演示";
 }
 public void interceptGridData(List<Map<String, Object>> list)
 throws Exception {
 for (Map<String, Object> user : list) {
 if (user.get("administrator") != null) {
 user.put("administrator",((Boolean) user.get("administrator")) == true ? "是": "否");
 }
 if (user.get("enabled") != null) {
 user.put("enabled",((Boolean) user.get("enabled")) == true ? "是" : "否");
 }
 }
 Map<String, Object> insertUser=new HashMap<String, Object>();
 insertUser.put("username", "user4");
 insertUser.put("cname", "user4");
 insertUser.put("ename", "user4");
 list.add(insertUser);
 }
 public void interceptAutoFormData(List<Map<String, Object>> list)
 throws Exception {
 }
}
同時(shí),在Export2ReportAction控件中指定屬性interceptorName為userReportDataInterceptor,導(dǎo)出顯示效果如下圖所示,

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)