function PersonnelFile() {
var common = new BT.common();
common.clear('centerTabPanel');
var toptoolbar = new Ext.Toolbar({
buttons: [ {
iconCls: 'excel'
, text: '导出'
, handler: PersonLeadToExcel
}
]
});
//数据源
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({ url: 'BTSystemOA/btrlzy/PersonalManagement/SearchPerson.ashx', method: 'POST' }),
reader: new Ext.data.JsonReader({
totalProperty: 'totalCount', //总的数据条数
root: 'data',
successProperty: 'success'
}, [
{ name: 'cEmployeeNo', type: 'string' }
, { name: 'cTrueName', type: 'string' }
, { name: 'cSex', type: 'string' }
, { name: 'cNatives', type: 'string' }
, { name: 'cEducation', type: 'string' }
, { name: 'cJobName', type: 'string' }
, { name: 'cDeptName', type: 'string' }
, { name: 'dOnDutyDate', type: 'string' }
, { name: 'TPactDate', type: 'string' }
, { name: 'FPactDate', type: 'string' }
]
),
remoteSort: true,
sortInfo: { field: 'cEmployeeNo', direction: 'ASC' },
autoload: true,
baseParams: { cEmployeeNo: '', cTrueName: '', cEducation: '', dOnDutyDate: '', cJobName: '', cDeptName: '', cState: '', TPactDate: '', FPactDate: '' }
});
var PersonnelFile = new Ext.Panel({
id: 'PersonnelFile'
, title: '人员档案'
, autoDestroy: true
, closable: true
, layout: 'fit'
, tbar: toptoolbar
});
var rowNumber = new Ext.grid.RowNumberer({
width: 35,
header: "序号"
}); //分页工具栏
var page_toolbar = new BT.ux.PageSizeComboToolbar({
pageSize: 50,
store: store
});
//表格
var PersonnelGrid = new Ext.grid.GridPanel({
id: 'PersonnelGrid',
bodyStyle: 'widht:100%;height:100%;',
store: store,
cm: new Ext.ux.grid.LockingColumnModel([rowNumber,
{ header: "人员编码", dataIndex: "cEmployeeNo", sortable: true, width: 100, id: 'index' },
{ header: "姓名", dataIndex: "cTrueName", sortable: true, width: 80 },
{ header: "性别", dataIndex: "cSex", sortable: true, width: 50 },
{ header: "籍贯", dataIndex: "cNatives", sortable: true, width: 100 },
{ header: "学历", dataIndex: "cEducation", sortable: true, width: 50 },
{ header: "岗位名称", dataIndex: "cJobName", sortable: true, width: 150 },
{ header: "部门名称", dataIndex: "cDeptName", sortable: true, width: 150 },
{ header: "入职日期", dataIndex: "dOnDutyDate", sortable: true, width: 150 },
{ header: "合同日期", dataIndex: "TPactDate", sortable: true, width: 150 },
{ header: "合同到期", dataIndex: "FPactDate", sortable: true, width: 150 }
]),
// view: new Ext.ux.grid.LockingGridView(),
trackMouseOver: true,
disableSelection: false,
loadMask: true,
autoExpandColumn: 10,
stripeRows: true,
bbar: page_toolbar
});
PersonnelFile.add(PersonnelGrid);
Ext.getCmp("centerTabPanel").add(PersonnelFile);
Ext.getCmp("centerTabPanel").setActiveTab(PersonnelFile);
Ext.getCmp("centerTabPanel").doLayout();
}
//-----------------------------------------------导出Excel-------------------------------------
function PersonLeadToExcel() {
Ext.Ajax.request({
url: "BTSystemOA/btrlzy/PersonLeadToExcel.ashx"
, async: false
, method: "POST"
, params: { cEmployeeNo:Ext.getCmp('cEmployeeNo').getValue(),
cTrueName:Ext.getCmp(cTrueName).getValue(),
cEducation: Ext.getCmp(cEducation).getValue()
}
});}
前台.js文件//-------PersonLeadToExcelExcel.ashx-------- string constr = System.Configuration.ConfigurationManager.ConnectionString["connStr"].ConnectionString;
string sql=".........";
DataTable dt = SqlHelper.ExecuteDataset(constr, CommandType.Text, sql).Tables[0];后台的代码
1.如何现实导出Excel?可以在我的代码前提下改动
2.为什么用datatable导不出Excel,没反应
var common = new BT.common();
common.clear('centerTabPanel');
var toptoolbar = new Ext.Toolbar({
buttons: [ {
iconCls: 'excel'
, text: '导出'
, handler: PersonLeadToExcel
}
]
});
//数据源
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({ url: 'BTSystemOA/btrlzy/PersonalManagement/SearchPerson.ashx', method: 'POST' }),
reader: new Ext.data.JsonReader({
totalProperty: 'totalCount', //总的数据条数
root: 'data',
successProperty: 'success'
}, [
{ name: 'cEmployeeNo', type: 'string' }
, { name: 'cTrueName', type: 'string' }
, { name: 'cSex', type: 'string' }
, { name: 'cNatives', type: 'string' }
, { name: 'cEducation', type: 'string' }
, { name: 'cJobName', type: 'string' }
, { name: 'cDeptName', type: 'string' }
, { name: 'dOnDutyDate', type: 'string' }
, { name: 'TPactDate', type: 'string' }
, { name: 'FPactDate', type: 'string' }
]
),
remoteSort: true,
sortInfo: { field: 'cEmployeeNo', direction: 'ASC' },
autoload: true,
baseParams: { cEmployeeNo: '', cTrueName: '', cEducation: '', dOnDutyDate: '', cJobName: '', cDeptName: '', cState: '', TPactDate: '', FPactDate: '' }
});
var PersonnelFile = new Ext.Panel({
id: 'PersonnelFile'
, title: '人员档案'
, autoDestroy: true
, closable: true
, layout: 'fit'
, tbar: toptoolbar
});
var rowNumber = new Ext.grid.RowNumberer({
width: 35,
header: "序号"
}); //分页工具栏
var page_toolbar = new BT.ux.PageSizeComboToolbar({
pageSize: 50,
store: store
});
//表格
var PersonnelGrid = new Ext.grid.GridPanel({
id: 'PersonnelGrid',
bodyStyle: 'widht:100%;height:100%;',
store: store,
cm: new Ext.ux.grid.LockingColumnModel([rowNumber,
{ header: "人员编码", dataIndex: "cEmployeeNo", sortable: true, width: 100, id: 'index' },
{ header: "姓名", dataIndex: "cTrueName", sortable: true, width: 80 },
{ header: "性别", dataIndex: "cSex", sortable: true, width: 50 },
{ header: "籍贯", dataIndex: "cNatives", sortable: true, width: 100 },
{ header: "学历", dataIndex: "cEducation", sortable: true, width: 50 },
{ header: "岗位名称", dataIndex: "cJobName", sortable: true, width: 150 },
{ header: "部门名称", dataIndex: "cDeptName", sortable: true, width: 150 },
{ header: "入职日期", dataIndex: "dOnDutyDate", sortable: true, width: 150 },
{ header: "合同日期", dataIndex: "TPactDate", sortable: true, width: 150 },
{ header: "合同到期", dataIndex: "FPactDate", sortable: true, width: 150 }
]),
// view: new Ext.ux.grid.LockingGridView(),
trackMouseOver: true,
disableSelection: false,
loadMask: true,
autoExpandColumn: 10,
stripeRows: true,
bbar: page_toolbar
});
PersonnelFile.add(PersonnelGrid);
Ext.getCmp("centerTabPanel").add(PersonnelFile);
Ext.getCmp("centerTabPanel").setActiveTab(PersonnelFile);
Ext.getCmp("centerTabPanel").doLayout();
}
//-----------------------------------------------导出Excel-------------------------------------
function PersonLeadToExcel() {
Ext.Ajax.request({
url: "BTSystemOA/btrlzy/PersonLeadToExcel.ashx"
, async: false
, method: "POST"
, params: { cEmployeeNo:Ext.getCmp('cEmployeeNo').getValue(),
cTrueName:Ext.getCmp(cTrueName).getValue(),
cEducation: Ext.getCmp(cEducation).getValue()
}
});}
前台.js文件//-------PersonLeadToExcelExcel.ashx-------- string constr = System.Configuration.ConfigurationManager.ConnectionString["connStr"].ConnectionString;
string sql=".........";
DataTable dt = SqlHelper.ExecuteDataset(constr, CommandType.Text, sql).Tables[0];后台的代码
1.如何现实导出Excel?可以在我的代码前提下改动
2.为什么用datatable导不出Excel,没反应
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货