をエクスポートしています。私はいくつかのコードを持っています:GridViewのは、私が得意とするGridViewの内容をエクスポートしようとしています全体のaspxページ
public void ExcelDownload(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.Charset = "UTF-8";
Response.AppendHeader("Content-Disposition", "attachment;filename=MailingList.xls");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
Response.ContentType = "application/ms-excel";
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("EN-US", true);
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
MailingList.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
}
リンクがクリックされたときに実行されます。これは、gridview(MailingList)の代わりにWebページ全体をエクスポートしていることを除いて、正常に動作します。誰もがこれを修正する方法を知っていますか?
[OK]を、私は今、EPPlusをしようとしています。それがうまく動作します!ご協力いただきありがとうございます。 – shawleigh17
ああ、それは素晴らしい作品、あなたがhttp://stackoverflow.com/questions/9569401/c-sharp-create-modify-read-xlsx-files/9569827#9569827をXLSXにここのDataTableをエクスポートする例を見ることができます –