嗨,是否有機會從gridview更改導出數據的標題名稱。下面是我的代碼,它的工作正常。我唯一的問題是我無法改變的頭名將Gridview數據導出到Excel - 更改標題名稱
我的代碼
Dim strFilename As String = Now.Date.Month.ToString + Now.Date.Day.ToString + Now.Hour.ToString + Now.Minute.ToString + Now.Second.ToString
Response.AddHeader("content-disposition", "attachment;filename=" & strFilename & ".xls")
Response.Clear()
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel"
Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(stringWrite)
Dim dg As System.Web.UI.WebControls.DataGrid = New System.Web.UI.WebControls.DataGrid()
dg.DataSource = dt
dg.DataBind()
dg.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString())
Response.End()
結果是
ID Fname
1 aaa
2 bbb
2 ccc
我想這樣
Employee ID First Name
1 aaa
2 bbb
3 ccc
即時通訊使用gridview和我有一個列名 – spy
好....我已經更新了我的答案是一個GridView。我正在處理您的代碼示例,如果它不反映您的問題,請更新它,以便我可以更好地爲您提供幫助。 –
先生其不工作 - 即時通訊使用模板字段.. – spy