我有数据网格的格式问题。我已经应用了格式属性aDataColumn.DataFormatString = "{0:d}"
Private Function CreateColumnFromNode(ByVal aDisplayPropertyNode As XmlNode) As BoundColumn
Dim PropertyKey As String = cXMLDoc.AttributeToString(aDisplayPropertyNode, "PropertyKey")
Dim ColumnHeader As String = ConfigurableText(cXMLDoc.AttributeToString(aDisplayPropertyNode, "ColumnHeader"))
If PropertyKey = "" Then Return Nothing
Dim aDataColumn As New BoundColumn()
aDataColumn.DataField = PropertyKey
aDataColumn.HeaderText = IIf(ColumnHeader = "", PropertyKey, ColumnHeader)
<b> aDataColumn.DataFormatString = "{0:d}"</b>
Return aDataColumn
End Function
到数据网格。导出到 excel 时,它采用系统的默认设置。
我已使用以下代码进行导出。不是自定义代码。
它使用 asp.net 属性。
Dim response As HttpResponse = HttpContext.Current.Response
response.Clear()
response.Charset = ""
' set the response mime type
response.ContentType = "application/vnd.ms-excel"
response.AddHeader("Content-Disposition", "attachment;filename=" + aFileName)
' create a string writer
Using sw As System.IO.StringWriter = New System.IO.StringWriter()
Using htw As HtmlTextWriter = New HtmlTextWriter(sw)
' instantiate a datagrid
DataGrid1.RenderControl(htw)
response.Write(sw.ToString())
End Using
End Using
response.End()
谢谢..