- Ext.ux.ExcelPanel = function(config) {
- Ext.ux.ExcelPanel.superclass.constructor.call(this, Ext.apply(config, {
- ownerId : config.ownerId,
- xls : config.xls,
- parent : config.parent
- }));
- };
- /**
- * function SetReadOnly(IsReadOnly, PassWord ); 设置为只读 function
- * ShowCommandBar(CommandbarIndexOrName, IsShow); 显示或者隐藏指定的工具栏 function
- * ShowDialogType = { 0|1|2|3|4|5|6 } 0:新建对象 1:打开 2:保存 3:另存为 4:打印 5:打印设置 6:文件属性
- * function PrintOut( [in, optional] VARIANT PromptToSelectPrinter); 打印当前文档
- * function PrintPreview(); 显示打印预览视图 function Close();关闭当前文档 function
- * GetOfficeVer() 获取当前OFFICE的版本。 返回值的含义如下:
- * 9=Office2000,10=OfficeXP,11=Office2003,6=office95 8=office97 0=错误
- *
- * <code>
- * try {
- * this.dso.ShowDialog(3);
- * } catch (e) {
- * alert("保存Excel出错." + e.description);
- * }
- * </code
- *
- * @class Ext.ux.ExcelPanel
- * @extends Ext.Panel
- */
- ExtExt.ux.ExcelPanel = Ext.extend(Ext.Panel, {
- dso : null,
- isModified: false,
- isLoad : false,
- store : null,
- xls : null,
- zoom : 100,
- available : false,
- height : 700,
- width : 1200,
- datastartrow : 2,
- titles : ["序号", "姓名", "生日", "分数"],
- fields : ["id", "name", "birth", "score"],
- + " <param name='Statusbar' value='-1'>"
- + " <param name='BorderStyle' value='1'>"
- + " <PARAM NAME='BorderColor' VALUE='-2147483632'>"
- + " <PARAM NAME='BackColor' VALUE='-2147483643'> "
- + " <PARAM NAME='ForeColor' VALUE='-2147483640'> "
- + " <param name='TitlebarColor' value='42768'>"
- + " <param name='TitlebarTextColor' value='0'>"
- + " <PARAM NAME='Titlebar' VALUE='0'>"
- + " <PARAM NAME='Toolbars' VALUE='0'>"
- + " <PARAM NAME='Menubar' VALUE='0'>"
- + " <PARAM NAME='IsNoCopy' VALUE='0'>"
- // + " <param name='Caption' value='欢迎使用!'>"
- + " </object>",*/
- html : "<object classid='clsid:00460182-9E5E-11d5-B7C8-B8269041DD57' id='dso' CODEBASE='cab/dsoframer.cab#version=2,3,0,0'>"
- + "<PARAM NAME='_ExtentX' VALUE='16960'> "
- + "<PARAM NAME='_ExtentY' VALUE='13600'> "
- + "<PARAM NAME='BorderColor' VALUE='-2147483632'> "
- + "<PARAM NAME='BackColor' VALUE='-2147483643'> "
- + "<PARAM NAME='ForeColor' VALUE='-2147483640'> "
- + "<PARAM NAME='TitlebarColor' VALUE='-2147483635'> "
- + "<PARAM NAME='TitlebarTextColor' VALUE='-2147483634'> "
- + "<PARAM NAME='BorderStyle' VALUE='0'> "
- + "<PARAM NAME='Titlebar' VALUE='0'> "
- //+ "<PARAM NAME='Toolbars' VALUE='0'> "
- + "<PARAM NAME='Menubar' VALUE='0'>" + "</OBJECT>",
- initComponent : function() {
- this.createBtn = new Ext.Button({
- iconCls : 'ocx-create',
- text : '新建',
- tooltip : '新建',
- handler : this.create,
- scope : this
- });
- this.openBtn = new Ext.Button({
- iconCls : 'ocx-open',
- text : '打开',
- tooltip : '打开',
- handler : this.open,
- scope : this
- });
- this.saveCopyBtn = new Ext.Button({
- iconCls : 'ocx-saveas',
- text : '另存',
- tooltip : '另存',
- handler : this.saveCopy,
- scope : this
- });
- this.printBtn = new Ext.Button({
- iconCls : 'ocx-print',
- text : '打印',
- tooltip : '打印',
- handler : this.print,
- scope : this
- });
- this.previewBtn = new Ext.Button({
- iconCls : 'ocx-preview',
- text : '预览',
- tooltip : '打印预览',
- handler : this.preview,
- scope : this
- });
- this.zoominBtn = new Ext.Button({
- iconCls : 'ocx-zoomin',
- text : '放大',
- tooltip : '放大',
- handler : this.zoomin,
- scope : this
- });
- this.zoomoutBtn = new Ext.Button({
- iconCls : 'ocx-zoomout',
- text : '缩小',
- tooltip : '缩小',
- handler : this.zoomout,
- scope : this
- });
- this.closeBtn = new Ext.Button({
- text : '关闭',
- iconCls : 'ocx-close',
- tooltip : '关闭',
- handler : this.close,
- scope : this
- });
- this.loadBtn = new Ext.Button({
- text : '加载',
- iconCls : 'ocx-test',
- tooltip : '加载',
- handler : this.loadExcel,
- scope : this
- });
- this.saveBtn = new Ext.Button({
- text : '保存',
- iconCls : 'xy-save',
- tooltip : '加载',
- handler : this.saveExcel,
- scope : this
- });
- this.submitBtn = new Ext.Button({
- text : '提交',
- iconCls : 'ocx-test',
- tooltip : '提交',
- handler : this.submitExcel,
- scope : this
- });
- this.getBtn = new Ext.Button({
- text : '当前单元格',
- iconCls : 'ocx-test',
- handler : this.getActiveCellValue,
- scope : this
- });
- this.setBtn = new Ext.Button({
- text : '当前单元格设值',
- iconCls : 'xy-edit',
- handler : this.setActiveCellValue,
- scope : this
- });
- this.setFormulaBtn = new Ext.Button({
- text : '返回公式 ',
- iconCls : 'xy-edit',
- handler : this.setValueback,
- scope : this
- });
- this.testBtn = new Ext.Button({
- text : '测试',
- iconCls : 'ocx-test',
- handler : this.test,
- scope : this
- });
- this.tbar = [this.createBtn, this.openBtn, this.saveBtn,
- this.saveCopyBtn, this.printBtn, this.zoominBtn,
- this.zoomoutBtn, this.closeBtn, /*this.submitBtn, this.getBtn,*/ this.testBtn,
- {xtype:"tbfill"}, this.setBtn ,this.setFormulaBtn];
- Ext.ux.ExcelPanel.superclass.initComponent.call(this);
- this.addEvents('afterrender');
- },
- afterRender : function() {
- Ext.ux.ExcelPanel.superclass.afterRender.call(this);
- if (!Ext.isIE) {
- Ext.Msg.alert("提示", "本组件采用ActiveX控件, 只支持IE浏览器,请切换至IE浏览器使用.");
- return;
- }
- if (typeof(dso) == 'undefined')
- this.dso = document.getElementById("dso");
- else
- this.dso = dso;
- if (!dso) {
- alert("加载DsoFramer出错,请先注册组件.");
- } else {// do sizing
- dso.width = this.getInnerWidth();
- dso.height = this.getInnerHeight();
- this.on("resize", function(ep) {
- dso.width = ep.getInnerWidth();
- dso.height = ep.getInnerHeight();
- });
- }
- // this.fireEvent("afterrender", this);
- /*
- * if (this.dso) { if (this.xls) { this.loadExcel(this.xls); } else {
- * this.create(); if (this.store) { if (!this.store.data) {
- * } } } }
- */
- },
- btnDisable : function() {
- this.saveCopyBtn.disable();
- this.printBtn.disable();
- this.previewBtn.disable();
- this.zoominBtn.disable();
- this.zoomoutBtn.disable();
- this.loadBtn.disable();
- this.submitBtn.disable();
- this.closeBtn.disable();
- },
- btnEnable : function() {
- this.saveCopyBtn.enable();
- this.printBtn.enable();
- this.previewBtn.enable();
- this.zoominBtn.enable();
- this.zoomoutBtn.enable();
- this.loadBtn.enable();
- this.submitBtn.enable();
- this.closeBtn.enable();
- }
- });