1. Ext.ux.ExcelPanel = function(config) { 
  2.     Ext.ux.ExcelPanel.superclass.constructor.call(this, Ext.apply(config, { 
  3.                         ownerId : config.ownerId, 
  4.                         xls : config.xls, 
  5.                         parent : config.parent 
  6.                     })); 
  7. }; 
  8.  
  9. /** 
  10.  * function SetReadOnly(IsReadOnly, PassWord ); 设置为只读 function 
  11.  * ShowCommandBar(CommandbarIndexOrName, IsShow); 显示或者隐藏指定的工具栏 function 
  12.  * ShowDialogType = { 0|1|2|3|4|5|6 } 0:新建对象 1:打开 2:保存 3:另存为 4:打印 5:打印设置 6:文件属性 
  13.  * function PrintOut( [in, optional] VARIANT PromptToSelectPrinter); 打印当前文档 
  14.  * function PrintPreview(); 显示打印预览视图 function Close();关闭当前文档 function 
  15.  * GetOfficeVer() 获取当前OFFICE的版本。 返回值的含义如下: 
  16.  * 9=Office200010=OfficeXP,11=Office20036=office95 8=office97 0=错误 
  17.  *  
  18.  * <code> 
  19.  *      try { 
  20.  *          this.dso.ShowDialog(3); 
  21.  *      } catch (e) { 
  22.  *          alert("保存Excel出错." + e.description); 
  23.  *      } 
  24.  *  </code 
  25.  *  
  26.  * @class Ext.ux.ExcelPanel 
  27.  * @extends Ext.Panel 
  28.  */ 
  29. ExtExt.ux.ExcelPanel = Ext.extend(Ext.Panel, { 
  30.     dso : null, 
  31.     isModified: false, 
  32.     isLoad : false, 
  33.     store : null, 
  34.     xls : null, 
  35.     zoom : 100, 
  36.     available : false, 
  37.     height : 700, 
  38.     width : 1200, 
  39.     datastartrow : 2, 
  40.     titles : ["序号", "姓名", "生日", "分数"], 
  41.     fields : ["id", "name", "birth", "score"], 
  42.             + " <param name='Statusbar' value='-1'>
  43.             + " <param name='BorderStyle' value='1'>
  44.             + " <PARAM NAME='BorderColor' VALUE='-2147483632'>
  45.             + " <PARAM NAME='BackColor' VALUE='-2147483643'>    " 
  46.             + " <PARAM NAME='ForeColor' VALUE='-2147483640'>    " 
  47.             + " <param name='TitlebarColor' value='42768'>
  48.             + " <param name='TitlebarTextColor' value='0'>
  49.             + " <PARAM NAME='Titlebar' VALUE='0'>
  50.             + " <PARAM NAME='Toolbars' VALUE='0'>
  51.             + " <PARAM NAME='Menubar' VALUE='0'>
  52.             + " <PARAM NAME='IsNoCopy' VALUE='0'>
  53.             // + " <param name='Caption' value='欢迎使用!'>
  54.             + " </object>",*/ 
  55.     html : "<object classid='clsid:00460182-9E5E-11d5-B7C8-B8269041DD57' id='dso' CODEBASE='cab/dsoframer.cab#version=2,3,0,0'>
  56.                     + "<PARAM NAME='_ExtentX' VALUE='16960'>    " 
  57.                     + "<PARAM NAME='_ExtentY' VALUE='13600'>    " 
  58.                     + "<PARAM NAME='BorderColor' VALUE='-2147483632'>   " 
  59.                     + "<PARAM NAME='BackColor' VALUE='-2147483643'> " 
  60.                     + "<PARAM NAME='ForeColor' VALUE='-2147483640'> " 
  61.                     + "<PARAM NAME='TitlebarColor' VALUE='-2147483635'> " 
  62.                     + "<PARAM NAME='TitlebarTextColor' VALUE='-2147483634'> " 
  63.                     + "<PARAM NAME='BorderStyle' VALUE='0'> " 
  64.                     + "<PARAM NAME='Titlebar' VALUE='0'>    " 
  65.                     //+ "<PARAM NAME='Toolbars' VALUE='0'>  " 
  66.                     + "<PARAM NAME='Menubar' VALUE='0'>" + "</OBJECT>", 
  67.     initComponent : function() { 
  68.         this.createBtn = new Ext.Button({ 
  69.                     iconCls : 'ocx-create', 
  70.                     text : '新建', 
  71.                     tooltip : '新建', 
  72.                     handler : this.create, 
  73.                     scope : this 
  74.                 }); 
  75.         this.openBtn = new Ext.Button({ 
  76.                     iconCls : 'ocx-open', 
  77.                     text : '打开', 
  78.                     tooltip : '打开', 
  79.                     handler : this.open, 
  80.                     scope : this 
  81.                 }); 
  82.         this.saveCopyBtn = new Ext.Button({ 
  83.                     iconCls : 'ocx-saveas', 
  84.                     text : '另存', 
  85.                     tooltip : '另存', 
  86.                     handler : this.saveCopy, 
  87.                     scope : this 
  88.                 }); 
  89.         this.printBtn = new Ext.Button({ 
  90.                     iconCls : 'ocx-print', 
  91.                     text : '打印', 
  92.                     tooltip : '打印', 
  93.                     handler : this.print, 
  94.                     scope : this 
  95.                 }); 
  96.         this.previewBtn = new Ext.Button({ 
  97.                     iconCls : 'ocx-preview', 
  98.                     text : '预览', 
  99.                     tooltip : '打印预览', 
  100.                     handler : this.preview, 
  101.                     scope : this 
  102.                 }); 
  103.         this.zoominBtn = new Ext.Button({ 
  104.                     iconCls : 'ocx-zoomin', 
  105.                     text : '放大', 
  106.                     tooltip : '放大', 
  107.                     handler : this.zoomin, 
  108.                     scope : this 
  109.                 }); 
  110.         this.zoomoutBtn = new Ext.Button({ 
  111.                     iconCls : 'ocx-zoomout', 
  112.                     text : '缩小', 
  113.                     tooltip : '缩小', 
  114.                     handler : this.zoomout, 
  115.                     scope : this 
  116.                 }); 
  117.         this.closeBtn = new Ext.Button({ 
  118.                     text : '关闭', 
  119.                     iconCls : 'ocx-close', 
  120.                     tooltip : '关闭', 
  121.                     handler : this.close, 
  122.                     scope : this 
  123.                 }); 
  124.         this.loadBtn = new Ext.Button({ 
  125.                     text : '加载', 
  126.                     iconCls : 'ocx-test', 
  127.                     tooltip : '加载', 
  128.                     handler : this.loadExcel, 
  129.                     scope : this 
  130.                 }); 
  131.         this.saveBtn = new Ext.Button({ 
  132.                     text : '保存', 
  133.                     iconCls : 'xy-save', 
  134.                     tooltip : '加载', 
  135.                     handler : this.saveExcel, 
  136.                     scope : this 
  137.                 }); 
  138.         this.submitBtn = new Ext.Button({ 
  139.                     text : '提交', 
  140.                     iconCls : 'ocx-test', 
  141.                     tooltip : '提交', 
  142.                     handler : this.submitExcel, 
  143.                     scope : this 
  144.                 }); 
  145.         this.getBtn = new Ext.Button({ 
  146.                     text : '当前单元格', 
  147.                     iconCls : 'ocx-test', 
  148.                     handler : this.getActiveCellValue, 
  149.                     scope : this 
  150.                 }); 
  151.         this.setBtn = new Ext.Button({ 
  152.                     text : '当前单元格设值', 
  153.                     iconCls : 'xy-edit', 
  154.                     handler : this.setActiveCellValue, 
  155.                     scope : this 
  156.                 }); 
  157.         this.setFormulaBtn = new Ext.Button({ 
  158.                     text : '返回公式 ', 
  159.                     iconCls : 'xy-edit', 
  160.                     handler : this.setValueback, 
  161.                     scope : this 
  162.                 }); 
  163.         this.testBtn = new Ext.Button({ 
  164.                     text : '测试', 
  165.                     iconCls : 'ocx-test', 
  166.                     handler : this.test, 
  167.                     scope : this 
  168.                 }); 
  169.         this.tbar = [this.createBtn, this.openBtn, this.saveBtn, 
  170.                 this.saveCopyBtn, this.printBtn, this.zoominBtn, 
  171.                 this.zoomoutBtn, this.closeBtn, /*this.submitBtn, this.getBtn,*/ this.testBtn, 
  172.                     {xtype:"tbfill"}, this.setBtn ,this.setFormulaBtn]; 
  173.         Ext.ux.ExcelPanel.superclass.initComponent.call(this); 
  174.         this.addEvents('afterrender'); 
  175.     }, 
  176.     afterRender : function() { 
  177.         Ext.ux.ExcelPanel.superclass.afterRender.call(this); 
  178.  
  179.         if (!Ext.isIE) { 
  180.             Ext.Msg.alert("提示", "本组件采用ActiveX控件, 只支持IE浏览器,请切换至IE浏览器使用."); 
  181.             return; 
  182.         } 
  183.         if (typeof(dso) == 'undefined') 
  184.             this.dso = document.getElementById("dso"); 
  185.         else 
  186.             this.dso = dso; 
  187.  
  188.         if (!dso) { 
  189.             alert("加载DsoFramer出错,请先注册组件."); 
  190.         } else {// do sizing 
  191.             dso.width = this.getInnerWidth(); 
  192.             dso.height = this.getInnerHeight(); 
  193.  
  194.             this.on("resize", function(ep) { 
  195.                         dso.width = ep.getInnerWidth(); 
  196.                         dso.height = ep.getInnerHeight(); 
  197.                     }); 
  198.         } 
  199.         // this.fireEvent("afterrender", this); 
  200.  
  201.         /* 
  202.          * if (this.dso) { if (this.xls) { this.loadExcel(this.xls); } else { 
  203.          * this.create(); if (this.store) { if (!this.store.data) { 
  204.          *  } } } } 
  205.          */ 
  206.     }, 
  207.     btnDisable : function() { 
  208.         this.saveCopyBtn.disable(); 
  209.         this.printBtn.disable(); 
  210.         this.previewBtn.disable(); 
  211.         this.zoominBtn.disable(); 
  212.         this.zoomoutBtn.disable(); 
  213.         this.loadBtn.disable(); 
  214.         this.submitBtn.disable(); 
  215.         this.closeBtn.disable(); 
  216.     }, 
  217.     btnEnable : function() { 
  218.         this.saveCopyBtn.enable(); 
  219.         this.printBtn.enable(); 
  220.         this.previewBtn.enable(); 
  221.         this.zoominBtn.enable(); 
  222.         this.zoomoutBtn.enable(); 
  223.         this.loadBtn.enable(); 
  224.         this.submitBtn.enable(); 
  225.         this.closeBtn.enable(); 
  226.     } 
  227.      
  228.  
  229. });