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=office958=office970=错误
*
*
* try {
* this.dso.ShowDialog(3);
* } catch (e) {
* alert("保存Excel出错." + e.description);
* }
*
*
* @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"],
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
// + " "
+ " ",*/
html : ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
//+ ""
+ "" + "",
initComponent : function() {
this.createBtn=newExt.Button({
iconCls : 'ocx-create',
text : '新建',
tooltip : '新建',
handler : this.create,
scope : this
});
this.openBtn=newExt.Button({
iconCls : 'ocx-open',
text : '打开',
tooltip : '打开',
handler : this.open,
scope : this
});
this.saveCopyBtn=newExt.Button({
iconCls : 'ocx-saveas',
text : '另存',
tooltip : '另存',
handler : this.saveCopy,
scope : this
});
this.printBtn=newExt.Button({
iconCls : 'ocx-print',
text : '打印',
tooltip : '打印',
handler : this.print,
scope : this
});
this.previewBtn=newExt.Button({
iconCls : 'ocx-preview',
text : '预览',
tooltip : '打印预览',
handler : this.preview,
scope : this
});
this.zoominBtn=newExt.Button({
iconCls : 'ocx-zoomin',
text : '放大',
tooltip : '放大',
handler : this.zoomin,
scope : this
});
this.zoomoutBtn=newExt.Button({
iconCls : 'ocx-zoomout',
text : '缩小',
tooltip : '缩小',
handler : this.zoomout,
scope : this
});
this.closeBtn=newExt.Button({
text : '关闭',
iconCls : 'ocx-close',
tooltip : '关闭',
handler : this.close,
scope : this
});
this.loadBtn=newExt.Button({
text : '加载',
iconCls : 'ocx-test',
tooltip : '加载',
handler : this.loadExcel,
scope : this
});
this.saveBtn=newExt.Button({
text : '保存',
iconCls : 'xy-save',
tooltip : '加载',
handler : this.saveExcel,
scope : this
});
this.submitBtn=newExt.Button({
text : '提交',
iconCls : 'ocx-test',
tooltip : '提交',
handler : this.submitExcel,
scope : this
});
this.getBtn=newExt.Button({
text : '当前单元格',
iconCls : 'ocx-test',
handler : this.getActiveCellValue,
scope : this
});
this.setBtn=newExt.Button({
text : '当前单元格设值',
iconCls : 'xy-edit',
handler : this.setActiveCellValue,
scope : this
});
this.setFormulaBtn=newExt.Button({
text : '返回公式 ',
iconCls : 'xy-edit',
handler : this.setValueback,
scope : this
});
this.testBtn=newExt.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();
}
});