在ASP.NET中,我需要将数据库文件保存成XLS格式,但是在保存过程中,不能弹出保存文件对话框,请各位高手帮忙解决一下,谢谢了!
//执行保存
protected void save(DataSet ds, string title)
{
Application xlApp = new ApplicationClass();
xlApp = ExportDataGridToExcel(ds, title);
xlApp.Visible = true;
xlApp.ActiveWorkbook.SaveAs("7.XLS", XlFileFormat.xlExcel9795, null, null, false, false, XlSaveAsAccessMode.xlNoChange, null, null, null, null, null);
xlApp = null;
GC.Collect();
GC.WaitForPendingFinalizers();
}
//执行保存
protected void save(DataSet ds, string title)
{
Application xlApp = new ApplicationClass();
xlApp = ExportDataGridToExcel(ds, title);
xlApp.Visible = true;
xlApp.ActiveWorkbook.SaveAs("7.XLS", XlFileFormat.xlExcel9795, null, null, false, false, XlSaveAsAccessMode.xlNoChange, null, null, null, null, null);
xlApp = null;
GC.Collect();
GC.WaitForPendingFinalizers();
}
{
response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
response.Charset = "utf-8";
response.AddFileDependency(fileName);
response.ContentType = "text/xls";
response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName);
response.WriteFile(filePathCash);
response.End();
}
Response.AppendHeader("Content-Disposition","attachment; filename="+ System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes("港口代码.xls")) );
Response.AppendHeader("Content-Disposition","attachment; filename="+ System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes("港口代码.xls")) );
Response.Redirect("http://test/123.xls")