0
想知道是否有人可以協助。我有一個.ashx文件,它創建一個用C#DataGrid填充的Excel文檔。這一切都很好,唯一的問題是當我打開excel文檔時,自動網格線被關閉。有沒有辦法啓用它們?DataGrid擅長不顯示自動網格線
由於提前, 空氣
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.Charset = "";
response.ContentEncoding = System.Text.Encoding.Default;
response.ContentType = "application/vnd.ms-excel";
response.AddHeader("Content-Disposition", "attachment;filename=\"dataImportTemplate.xls\"");
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
System.Web.UI.WebControls.DataGrid dg = new System.Web.UI.WebControls.DataGrid();
dg.DataSource = ds.Tables[0];
dg.ShowHeader = false;
dg.DataBind();
dg.RenderControl(htw);
response.Write(sw.ToString());
}
}
請告訴我們,創建Excel文檔 – HatSoft 2012-07-11 09:28:43
嗨的代碼,我已經添加代碼到原來的職位 – Jebanisa 2012-07-11 09:37:44
嘗試設置DataGrid的邊框顏色,邊框樣式和邊框寬度你將它傳遞給RESPONSE.WRITE – HatSoft 2012-07-11 10:10:51