asp导出报表问题 导不出来
//导出为Excelfunction ExportExcel()
{
var delID = document.all.hid_clickedTreeID.value;
if(delID=="null" || delID==""){alert("<%=strNoOutTable%>");return false;}
//alert(typeof(EXPORT_OBJECT));
if(typeof(EXPORT_OBJECT)!="object")
{
document.body.insertAdjacentHTML("afterBegin","<OBJECT style='display:none' classid=clsid:0002E510-0000-0000-C000-000000000046 id=EXPORT_OBJECT></Object>");
}
with (EXPORT_OBJECT)
{
DataType = "HTMLData";
HTMLData=document.all.divSummaryResult.outerHTML;
//alert(HTMLData);
try{
alert(1);
ActiveSheet.Export("C:\\<%=strNoTitle%>.xls", 1);
alert(2);
alert('<%=strOutSuccess%>');
}
catch (e){
}
}
} --------------------编程问答-------------------- 天知道,你用到了一个ActiveX控件,这个控件怎么实现的,有没有被执行,你让人猜? --------------------编程问答-------------------- 就是没有执行,那么怎么才能让它执行呢
这项目不是我做的,现在出问题让我搞,所以我也看不懂
有哪位大大会的教一下哈!
无限感激 --------------------编程问答-------------------- 怎么样改不用ActiveX控件 --------------------编程问答--------------------
也就是导出excle文件
我用的是grodiview
如下
测试没问题
gvUsbUseUser.DataSource = dt2;
string srcPath = "xxx.xls";
FileInfo fileInfo = new FileInfo(srcPath);
Response.Clear();
Response.Buffer = true;
HttpContext.Current.Response.Write("<meta http-equiv=Content-Type content=text/html;charset=UTF-8>"); //编码
string fileName = HttpUtility.UrlEncode(srcPath + ".xls", Encoding.GetEncoding("UTF-8"));//编码
HttpContext.Current.Response.AddHeader("content-disposition",
"attachment;filename=" + fileName);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
sgvAUOlocality.AllowPaging = false;//分页false
sgvAUOlocality.DataBind(); //查询数据的方法
sgvAUOlocality.RenderControl(htmlWrite);//gvUsbUseUser控件名 USB使用用户
Response.Write(stringWrite.ToString());
Response.End();
sgvAUOlocality.AllowPaging = true;//分页true
补充:.NET技术 , ASP.NET