var oXL = null;
var workbookType = 0; //默认为excel,用0表示,1表示金山表格
//获得workbook对象
try {
if(oXL==null){
oXL = new ActiveXObject("Excel.Application");
}
}catch(e) {
//alert("不能正确调用Excel,请确认是否已经将网站设置为安全站点且Excel已安装");
//return;
try {
oXL = new ActiveXObject("ET.Application");
workbookType = 1;
}catch(e) {
alert("Excel和金山表格均不能正确调用,请确认是否已经将网站设置为安全站点且Excel或金山表格已安装");
return;
}
}
//获得workbook
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
oSheet.rows(1).RowHeight = 1/0.035; // 设置高度=1厘米
oSheet.Rows(1).Font.Size=16;
oSheet.Rows(1).Font.Bold=true;
oSheet.Columns("A").ColumnWidth =20;//设置列宽
oSheet.Columns("B").ColumnWidth =20;
oSheet.Columns("c").ColumnWidth =20;
oSheet.Cells(1,1).value = "分类";
oSheet.Cells(1,2).value = "报送时间";
oSheet.Cells(1,3).value = "事发地点";
for(var i = 0;i < chiloubao.length;i++){
oSheet.Cells(i+2,1).value = fenlei[i];
oSheet.Cells(i+2,2).value = bstime[i];
oSheet.Cells(i+2,3).value = place[i];
}
oXL.Application.Visible = true;//导出的文档是否可见(放在最后当加载完数据再显示word)