EXport to excel Issue [英] EXport to excel Issue
问题描述
string filename =FY15输入集合模板_+ ddlcity.SelectedItem.Text +。xls;
Response.AddHeader(content-disposition,attachment; filename =+ filename) ;
Response.Charset =UTF-8;
Response.ContentType =application / vnd.ms-excel;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
Microsoft.Office.Interop.Excel.ApplicationClass _ExcelApp = new Microsoft.Office.Interop。 Excel.ApplicationClass();
_ExcelApp.DisplayAlerts = false;
tbcity.RenderControl(hw);
tbannualpercent.RenderControl(hw);
tblasm.RenderControl(hw);
tbtwotable.RenderControl(hw);
tbsectb.RenderControl(hw);
tbthreetb.RenderControl(hw);
tbthirdtb.RenderControl(hw);
tbfourtb.RenderControl(hw);
tbfrtable。 RenderControl(hw);
this.EnableViewState = false;
Response.Write(tw.ToString());
Response.Flush();
Response.End();
当文件被下载时,当我们打开excel文件时,它显示弹出消息文件扩展已被破坏,你想打开任何一个,我怎么能抑制弹出消息任何帮助请......
string filename = "FY15 Input Collection Template_" + ddlcity.SelectedItem.Text+".xls" ;
Response.AddHeader("content-disposition", "attachment;filename=" + filename);
Response.Charset = "UTF-8";
Response.ContentType = "application/vnd.ms-excel";
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
Microsoft.Office.Interop.Excel.ApplicationClass _ExcelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
_ExcelApp.DisplayAlerts = false;
tbcity.RenderControl(hw);
tbannualpercent.RenderControl(hw);
tblasm.RenderControl(hw);
tbtwotable.RenderControl(hw);
tbsectb.RenderControl(hw);
tbthreetb.RenderControl(hw);
tbthirdtb.RenderControl(hw);
tbfourtb.RenderControl(hw);
tbfrtable.RenderControl(hw);
this.EnableViewState = false;
Response.Write(tw.ToString());
Response.Flush();
Response.End();
when the file is downloaded and when we tring to open the excel file its showing pop-up msg "FILE EXTENSIONS WERE CORRUPTED DO YOU WANT TO OPEN ANY WAy" how can i suppress that pop up message any help please......
推荐答案
您以xlsx格式创建了文件,但使用了扩展名.xls
。请改用.xlsx
扩展名。
You created the file in the xlsx format, but used the extension.xls
. Use the.xlsx
extension instead.
这篇关于EXport to excel Issue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!