- public native JavaScriptObject initExcel(String id, String strJSon,int count,String frozenColor) /*-{
- var $ = $wnd.$;
- var ss = "#"+id;
- $(ss).wijspread({sheetCount:count}); // create wijspread control
- var spread = $(ss).wijspread("spread"); // get instance of wijspread control
-
- //挂起绘制
- spread.isPaintSuspended(true);
-
- spread.fromJSON(JSON.parse(strJSon));
- spread.tabStripVisible(true);
- spread.grayAreaBackColor("white");
- var sheet = spread.getActiveSheet();
- sheet.setGridlineOptions({
- color: "#D9D9D9",
- showVerticalGridline:false,
- showHorizontalGridline:false
- });
- sheet.frozenlineColor(frozenColor);
- return spread;
- }-*/;
复制代码- private void buildView(){
- String strJSon="";
- if(formatData.length==2){
- strJSon=getExcelFormatAndDataJson(formatData);
- }else if(formatData.length==3 || formatData.length==4){
- String[] newFormatData={formatData[1],formatData[2]};
- strJSon=getExcelFormatAndDataJson(newFormatData);
- }else if(formatData.length==5 || formatData.length==6){
- strJSon=showBNBQData(this.QO,formatData);
- }
-
- if(strJSon==null || strJSon.equals("")){
- return;
- }
- this.viewJson=strJSon;
-
- JavaScriptObject spreadObj=null;
- String ldtype=this.PO.getString("ldtype", "init");
- if(ldtype.equals("init")){
- spreadObj=initExcel(this.getViewId(),strJSon,1,frozenLineColor);
- }else if(ldtype.equals("refresh")){
- spreadObj=initExcelData(this.getViewId(),strJSon,1,frozenLineColor);
- }
- this.setSpread(spreadObj);
- //设置锁定列
- int fccount=0;
- if(this.frozenColCount!=null && this.frozenColCount.trim().length()>0){
- fccount=Integer.parseInt(this.frozenColCount);
- }
- initExcelLockColumn(this.getSpread(),fccount);
-
- //设置分级
- initExcelGroup(this.getSpread(),0);
-
- if(hideRowHeader){
- this.hideRowHeader(this.getSpread());
- }
- if(hideColHeader){
- this.hideColHeader(this.getSpread());
- }
-
- if(!hideFooter){
- this.hideFooter(this.getSpread());
- }
- String hideScroll=this.PO.getString("hideScroll", "");
- if(hideScroll.equals("1")){
- hideHorizontalScrollbar(this.getSpread());
- hideVerticalScrollbar(this.getSpread());
- }
-
-
- //设置超链接样式
- if(linkQueryCols!=null && linkQueryCols.trim().length()>0){
- String lkCol[]=linkQueryCols.split(",");
- for(int c=0;c<lkCol.length;c++){
- int hcolIndex=Integer.parseInt(lkCol[c]);
- setHyperlinkStyle(this.getSpread(),0,this.titleNum+this.headerNum,hcolIndex,"#0000FF");
- }
- }
- addCellClickListener(this.getSpread());
-
- processSameContentSpan();//处理相同内容是否合并
-
- setProtectCell(this.getSpread());
- setAutoFitRow(this.getSpread());
- //激活重新绘制
- suspendPaint(this.getSpread(),false);
- }
复制代码 加载数据的时候会走buildView方法。通过initExcel方法创建并返回spread对象。this.setSpread(spreadObj);将spread对象放入。addCellClickListener(this.getSpread());添加监听,即本帖第一个方法代码。
|