本文目錄一覽:
extjs 怎麼導出excel
text : “導出到excel”,
style : {
marginRight : ’20px’
},
handler : function() {
var vExportContent = gridpanel.getExcelXml(); //獲取數據
if (Ext.isIE8||Ext.isIE6 || Ext.isIE7 || Ext.isSafari
|| Ext.isSafari2 || Ext.isSafari3) { //判斷瀏覽器
var fd = Ext.get(‘frmDummy’);
if (!fd) {
fd = Ext.DomHelper.append(
Ext.getBody(), {
tag : ‘form’,
method : ‘post’,
id : ‘frmDummy’,
action : ‘exportUrl.jsp’,
target : ‘_blank’,
name : ‘frmDummy’,
cls : ‘x-hidden’,
cn : [ {
tag : ‘input’,
name : ‘exportContent’,
id : ‘exportContent’,
type : ‘hidden’
} ]
}, true);
}
fd.child(‘#exportContent’).set( {
value : vExportContent
});
fd.dom.submit();
} else {
document.location = ‘data:application/vnd.ms-excel;base64,’ + Base64
.encode(vExportContent);
}
}}
前台用extjs後台用java.如何導出excel報表
前台
new Ext.Button({
text:’導出EXCEL’,
handler:function(){
var appWindow = window.open(“getExecl.do”); //調action得到數據生成execl格式的數據,response發往前台
appWindow.focus();
}
})
後台: filename是導出的文件名,heads是excel表頭,datalist是數據
public void createExcelStream(HttpServletResponse response,String filename,String[] heads,ListString[] datalist){
try{
OutputStream os = response.getOutputStream();
WritableWorkbook wbook = Workbook.createWorkbook(os);
WritableSheet wsheet = wbook.createSheet(filename, 0);
for(int i=0 ; iheads.length ; i++) {
Label label =new Label(i,0 ,heads[i]);
wsheet.addCell(label);
}
for(int i=0 ;idatalist.size();i++) {
for(int j=0 ; jdatalist.get(i).length ; j++){
Label label =new Label(j,i+1 ,datalist.get(i)[j]);
wsheet.addCell(label);
}
}
response.setHeader(“Content-disposition”,”attachment;” +
“filename=”+ new String(filename.getBytes(“GBK”), “ISO_8859_1″) +”.xls”);
response.setContentType(“application/vnd.ms-excel”);
wbook.write();
wbook.close();
os.close();
}catch(Exception e){
e.printStackTrace();
}
} }
怎麼用extjs實現導出excel
text : “導出到excel”,
style : {
marginRight : ’20px’
},
handler : function() {
var vExportContent = gridpanel.getExcelXml(); //獲取數據
if (Ext.isIE8||Ext.isIE6 || Ext.isIE7 || Ext.isSafari
|| Ext.isSafari2 || Ext.isSafari3) { //判斷瀏覽器
var fd = Ext.get(‘frmDummy’);
if (!fd) {
fd = Ext.DomHelper.append(
Ext.getBody(), {
tag : ‘form’,
method : ‘post’,
id : ‘frmDummy’,
action : ‘exportUrl.jsp’,
target : ‘_blank’,
name : ‘frmDummy’,
cls : ‘x-hidden’,
cn : [ {
tag : ‘input’,
name : ‘exportContent’,
id : ‘exportContent’,
type : ‘hidden’
} ]
}, true);
}
fd.child(‘#exportContent’).set( {
value : vExportContent
});
fd.dom.submit();
} else {
document.location = ‘data:application/vnd.ms-excel;base64,’ + Base64
.encode(vExportContent);
}
}}
extjs導出Excel是小數為什麼只顯示兩位?
這個是需要自己設置的,只要您設置小數點後兩位,那麼就是兩位。
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/257786.html