0
我有一個網格視圖,我導出到網格視圖數據爲單詞,如下所示。網格視圖數據和樣式按我的預期工作。現在我想和新的標題行對Word文檔,併發送我的網格視圖數據 下。我必須在Response.Output.Write(sw.ToString())之前將標題添加到word文檔中;線。 請任何幫助。如何添加新的標題行asp.net Response.Output.Write?
親切的問候,
protected void ExportToExcel(object sender, EventArgs e)
{
string nowTarih = DateTime.Now.ToString("yyyy-MM-dd");
string excelNameExport = "attachment;filename=" + nowTarih + "_LT_Raporu.doc";
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", excelNameExport);
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
Response.ContentType = "application/vnd.ms-word";
using (StringWriter sw = new StringWriter())
{
HtmlTextWriter hw = new HtmlTextWriter(sw);
//To Export all pages
mygrid.AllowPaging = false;
this.gvBind();
if (mygrid.Rows.Count > 0)
{
mygrid.Height = new Unit(mygrid.RowStyle.Height.Value * mygrid.Rows.Count);
}
mygrid.DataBind();
mygrid.RenderControl(hw);
//style to format numbers to string
string style = @"<style> .textmode { } </style>";
Response.Write(style);
**Response.Output.Write(sw.ToString());**
Response.Flush();
Response.End();
}
}