// String packageName = "com.iisigroup.cap.service";
// String importClass = "com.iisigroup.cap.base.model.CaseInfo,com.iisigroup.cap.utils.CapDroolsUtil";r
// String variablesName = "com.iisigroup.cap.utils.CapDroolsUtil comUtil";
String divRlNo = request.get("divRlNo");
String oid = request.get("oid");
DivRlItm rlItm = ruleTbMntService.getByRlItmNo(divRlNo);
if(rlItm==null || rlItm.getDivRlDtls()==null){
return null;
}
//取得排序的Rule明細
List<DivRlDtl> rlDtls = ruleTbMntService.findRlDtlsByRlNoAndSort(rlItm.getDivRlNo());//rlItm.getDivRlDtls();
List<DivCtItm> ctItms = null;
WritableWorkbook workbook = null;
File relFile = null;
try{
File fileDir = new File("../Temp");
FileUtils.forceMkdir(fileDir);
// 使用Char(3.6) 取得承辦分行資料。
List<Map<String, Object>> lnf312Data = new ArrayList<Map<String,Object>>();
String BRNO = "", BRNM = "";
StringBuffer BRNoNm=new StringBuffer();
if(!CollectionUtils.isEmpty(lnf312Data)){
for(Map<String, Object> map : lnf312Data){
BRNO = MapUtils.getString(map, "BRNO")+" ";
BRNM = MapUtils.getString(map, "BRNM")+" ";
BRNoNm.append(BRNO).append(BRNM);
}
}
relFile = new File(fileDir + File.separator + CapDate.getCurrentDate("yyyyMMdd") + "_ruleExport.xls");
relFile.createNewFile();
// 2. 產生 workbook
workbook = Workbook.createWorkbook(relFile);
WritableSheet sheet1 = workbook.createSheet("Tables", 0);
WritableFont myFont = new WritableFont(WritableFont.createFont("Arial"), 12);
WritableFont boldWhiteFnt =
new WritableFont(WritableFont.createFont("Arial"), 12, WritableFont.BOLD);
boldWhiteFnt.setColour(Colour.WHITE);
WritableFont blackFnt =
new WritableFont(WritableFont.createFont("Arial"), 12, WritableFont.NO_BOLD);
blackFnt.setColour(Colour.BLACK);
// 第1行先放空白資料,並設定欄寬--->還沒設定
//DecisionTable起始先告區(黑底白字)
WritableCellFormat headCellFmt = new WritableCellFormat();
//自動換行
headCellFmt.setWrap(false);
//水平靠左
headCellFmt.setAlignment(Alignment.LEFT);
//垂直置中
headCellFmt.setVerticalAlignment(VerticalAlignment.TOP);
//設字形
headCellFmt.setFont(boldWhiteFnt);
//設欄位框(細)線
// headCellFmt.setBorder(Border.ALL,BorderLineStyle.THIN, Colour.BLACK);
//設定顏色
headCellFmt.setBackground(Colour.GRAY_80);
//DecisionTable內容橘底黑字
WritableCellFormat setCellFmt = new WritableCellFormat();
//自動換行
setCellFmt.setWrap(true);
//水平靠左
setCellFmt.setAlignment(Alignment.LEFT);
//垂直置中
setCellFmt.setVerticalAlignment(VerticalAlignment.TOP);
//設字形
setCellFmt.setFont(myFont);
//設欄位框(細)線
setCellFmt.setBorder(Border.ALL,BorderLineStyle.THIN, Colour.BLACK);
//設定顏色(粉橘色)
setCellFmt.setBackground(Colour.TAN);
//DecisionTable內容白底黑字
WritableCellFormat bodyCellFmt = new WritableCellFormat();
//自動換行
bodyCellFmt.setWrap(false);
//水平靠左
bodyCellFmt.setAlignment(Alignment.LEFT);
//垂直置中
bodyCellFmt.setVerticalAlignment(VerticalAlignment.TOP);
//設字形
bodyCellFmt.setFont(myFont);
//設欄位框(細)線
bodyCellFmt.setBorder(Border.ALL,BorderLineStyle.THIN, Colour.BLACK);
//設定顏色
// bodyCellFmt.setBackground(Colour.BLACK);
//DecisionTable內容藍底黑字
WritableCellFormat blueCellFmt = new WritableCellFormat();
//自動換行
blueCellFmt.setWrap(false);
//水平靠左
blueCellFmt.setAlignment(Alignment.LEFT);
//垂直置中
blueCellFmt.setVerticalAlignment(VerticalAlignment.TOP);
//設字形
blueCellFmt.setFont(myFont);
//設欄位框(細)線
blueCellFmt.setBorder(Border.ALL,BorderLineStyle.THIN, Colour.BLACK);
blueCellFmt.setBackground(Colour.LIGHT_TURQUOISE);
//DecisionTable內容黃底黑字
WritableCellFormat yellowCellFmt = new WritableCellFormat();
//自動換行
yellowCellFmt.setWrap(false);
//水平靠左
yellowCellFmt.setAlignment(Alignment.LEFT);
//垂直置中
yellowCellFmt.setVerticalAlignment(VerticalAlignment.TOP);
//設字形
yellowCellFmt.setFont(myFont);
//設欄位框(細)線
yellowCellFmt.setBorder(Border.ALL,BorderLineStyle.THIN, Colour.BLACK);
yellowCellFmt.setBackground(Colour.YELLOW);
//DecisionTable內容綠底黑字
WritableCellFormat greenCellFmt = new WritableCellFormat();
//自動換行
greenCellFmt.setWrap(false);
//水平靠左
greenCellFmt.setAlignment(Alignment.LEFT);
//垂直置中
greenCellFmt.setVerticalAlignment(VerticalAlignment.TOP);
//設字形
greenCellFmt.setFont(myFont);
//設欄位框(細)線
greenCellFmt.setBorder(Border.ALL,BorderLineStyle.THIN, Colour.BLACK);
greenCellFmt.setBackground(Colour.LIGHT_GREEN);
//設列高
// int row = 0;
// sheet1.setRowView(row,450);
//將第row行的欄寬設為100
// sheet1.setColumnView(row, 100);
// 合併儲存格(x,y, x1,y2)
// sheet1.mergeCells(0, row, 11, row);
// sheet1.addCell(new Label(0, 0, "", bodyCellFmt));
// sheet1.setColumnView(0, 26);
for(int i = 0; i < 65535; i++){
sheet1.setRowView(i+1,450);
sheet1.setColumnView(i, 23);
}
sheet1.setRowView(12,900);
//DecisionTable開頭宣告-參數
NumberFormat nf = new DecimalFormat("#.00");
sheet1.addCell(new Label(1, 2, "RuleSet", headCellFmt));
sheet1.addCell(new Label(1, 3, "Import", headCellFmt));
sheet1.addCell(new Label(1, 4, "EscapeQuotes", headCellFmt));
sheet1.addCell(new Label(1, 5, "Variables", headCellFmt));
sheet1.addCell(new Label(1, 6, "Functions", headCellFmt));
sheet1.addCell(new Label(1, 7, "Notes", headCellFmt));
sheet1.addCell(new Label(1, 9, "RuleTable "+ rlItm.getDivRlNm(), headCellFmt));
//DecisionTable開頭宣告-值
sheet1.addCell(new Label(2, 2, DroolsConstants.PACKAGE_NAME, headCellFmt));
sheet1.addCell(new Label(2, 3, DroolsConstants.IMPORT_CLASS, headCellFmt));
sheet1.addCell(new Label(2, 4, "false", headCellFmt));
sheet1.addCell(new Label(2, 5, DroolsConstants.VARIABLES_NAME, headCellFmt));
//設定均量化參數
sheet1.addCell(new Label(2, 6, "", headCellFmt));
sheet1.addCell(new Label(2, 7, "This is decision table for "+rlItm.getDivRlNm()
, headCellFmt));
sheet1.addCell(new Label(2, 9, "", headCellFmt));
//excel合併儲存格(著色)
for(int i = 0;i <6; i++){
sheet1.mergeCells(2, 2+i, 7, 2+i);