我那个是javascript脚本,目的就是把服务器的数据下载下来,格式是excel,参考大家的意见修改之后,可以直接通过IE运行,但是通过IIS运行的时候还是路径出现问题,呵呵,我把全部的javascript脚本文件都拷下来,如下,请大家帮忙看看。
function expExcel() {
var filePath = location.href.substring(0, location.href.lastIndexOf("excel.html"
);
var path = filePath+"cost.mdb";
//去掉字符串中最前面的"files://"这8个字符。
path = path.substring(8);
var conn;
conn = new ActiveXObject("ADODB.Connection"
;
conn.ConnectionString="provider=Microsoft.Jet.OLEDB.4.0;data source="+path;
conn.open;
var rs = new ActiveXObject("ADODB.RecordSet"
;
var sql= "select * from [cost].[test] where ID>2";
rs.open(sql, conn);
var exApp = new ActiveXObject("Excel.Application"
;
var exBook = exApp.Workbooks.Add();
var exSheet = exBook.ActiveSheet;
exApp.Visible = true;
exSheet.Cells(2,1).Value = "报表代码";
exSheet.Cells(2,2).Value = "使用部门";
exSheet.Cells(2,3).Value = "项目代码";
exSheet.Cells(2,4).Value = "项目名称";
exSheet.Cells(2,5).Value = "上年结余";
exSheet.Cells(2,6).Value = "本年预算";
exSheet.Cells(2,7).Value = "追加预算";
exSheet.Cells(2,8).Value = "调整预算";
exSheet.Cells(2,9).Value = "本年支出";
exSheet.Cells(2,10).Value = "年终调整金额";
exSheet.Cells(2,11).Value = "年末结余";
var rn=3;
while (!rs.eof) {
exSheet.Cells(rn,1).Value = rs.Fields("ysdm"
;
exSheet.Cells(rn,2).Value = rs.Fields("bm"
;
exSheet.Cells(rn,3).Value = rs.Fields("xmdm"
;
exSheet.Cells(rn,4).Value = rs.Fields("xmmc"
;
exSheet.Cells(rn,5).Value = rs.Fields("pjy"
;
exSheet.Cells(rn,6).Value = rs.Fields("sqys"
;
exSheet.Cells(rn,7).Value = rs.Fields("apys"
;
exSheet.Cells(rn,8).Value = rs.Fields("test8"
;
exSheet.Cells(rn,9).Value = rs.Fields("test9"
;
exSheet.Cells(rn,10).Value = rs.Fields("test10"
;
exSheet.Cells(rn,11).Value = rs.Fields("test11"
;
rn=rn+1;
rs.moveNext;
}
rn=null;
rs.close;
rs=null;
conn.close;
conn=null;
}