问题描述
i希望以pdf和Excel导出我的gridview,但扩展名不会显示我的代码
private void ExportGridToExcel()
{
Response.Clear();
Response.Buffer = true;
响应。 ClearContent();
Response.ClearHeaders();
Response.Charset =;
string FileName =WebQ-Tel-Data + DateTime.Now +.xls;
StringWriter strwritter = new StringWriter();
HtmlTextWriter htmltextwrtter = new HtmlTextWriter(strwritter);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType =application / vnd.ms-excel;
Response.AddHeader(Content-处理,附件; filename =+ FileName);
GridView1.GridLines = GridLines.Both;
GridView1.HeaderStyle.Font.Bold = true;
GridView1.RenderControl(htmltextwrtter);
Response.Write(strwritter.ToString());
Response.End();
}
private void ExportGridToPDF()
{
Response.ContentType =application / pdf;
Response.AddHeader(content-disposition, attachment; filename = WebQ-Tel-Data+ DateTime.Now +。pdf);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView1.HeaderRow.Cells [0] .Text =Date et heure;
GridView1.HeaderRow.Cells [0] .ForeColor = Color.Black;
GridView1.RenderControl(hw);
StringReader sr = new StringReader (sw.ToString());
文档pdfDoc =新文档(PageSize.A4,10f,10f,10f,0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc );
PdfWriter.GetInstance(pdfDoc,Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
GridView1.AllowPaging = true;
GridView1.DataBind();
}
,但谷歌浏览器工作原理
plzz我需要帮助
i want to export my gridview in pdf and Excel but the extension doesn't display thi's my code
private void ExportGridToExcel()
{
Response.Clear();
Response.Buffer = true;
Response.ClearContent();
Response.ClearHeaders();
Response.Charset = "";
string FileName = "WebQ-Tel-Data" + DateTime.Now + ".xls";
StringWriter strwritter = new StringWriter();
HtmlTextWriter htmltextwrtter = new HtmlTextWriter(strwritter);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName);
GridView1.GridLines = GridLines.Both;
GridView1.HeaderStyle.Font.Bold = true;
GridView1.RenderControl(htmltextwrtter);
Response.Write(strwritter.ToString());
Response.End();
}
private void ExportGridToPDF()
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=WebQ-Tel-Data" + DateTime.Now + ".pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView1.HeaderRow.Cells[0].Text = "Date et heure";
GridView1.HeaderRow.Cells[0].ForeColor = Color.Black;
GridView1.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
GridView1.AllowPaging = true;
GridView1.DataBind();
}
but in google chrome it works
plzz i need help
推荐答案
这篇关于如何在mozila firefox中显示pdf和Excel的扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!