<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
解决方案 »
- 2个ASP.NET(C#)网站登录的嵌入
- 在百度随便输入一个关键字,然后搜索出来的网页,有谁做过搜索出的网页,下面有很多链接页码,这种要怎么做,高手指点
- 请教: 密码框的制作,为了增强密码的安全性,像银行等的密码框原理?
- 如何在Web页面中实现类似Studio的缩放效果
- 为什么不出提示框??
- 缩略图问题
- 为什么我的DropDownList用了数据源就不能使用SelectedIndexChanged事件
- asp.net url编码后的参数javascript如何解码?
- 我如何用js能取到asp:dropdownlist的text,而不是value?
- 水晶报表多字段的显示
- 该如何找到对应的命名空间呢?比如:Request的命名空间C:\Inetpub\wwwroot\WebApplication32\dataaccess.cs(389): 找不到类型或命名空间
- 请问如何将数据放入到已经定义好的一个模板文件的表格中去
{
//export to excelResponse.Clear();
Response.Buffer= true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);this.ClearControls(dg);
dg.RenderControl(oHtmlTextWriter);Response.Write(oStringWriter.ToString());Response.End();
}
Dim oView As New DataView(ds.Tables(0))
DataGrid1.DataSource = oView
DataGrid1.DataBind() Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Response.ContentEncoding = System.Text.Encoding.Default '这行是解决乱码的关键 Me.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
DataGrid1.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
End Function
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">就行了,哈哈,送分了
Public Sub WriteDataBaseToExcelByStream(ByVal daReader As System.Data.SqlClient.SqlDataReader, ByVal FileName As String)
Dim numbercols As Integer = daReader.FieldCount
Dim row As Integer = 2
Dim i As Integer = 0
Dim fileLine As String Dim Fname As String = Request.PhysicalApplicationPath + "Exported\" + FileName
Dim drm As New System.IO.StreamWriter(Fname, False, System.Text.Encoding.Unicode) For i = 0 To numbercols - 1
fileLine += daReader.GetName(i).ToString() + ","
Next
drm.WriteLine(fileLine) While (daReader.Read())
fileLine = ""
For i = 0 To numbercols - 1
If daReader.GetValue(i).GetType() Is Nothing Then
fileLine += """"
Else
If daReader.GetValue(i).GetType Is GetType(String) Then
fileLine += """" + daReader.GetValue(i).ToString() + ""","
Else
fileLine += daReader.GetValue(i).ToString() + ","
End If
End If
Next
drm.WriteLine(fileLine)
row += 1
End While
drm.Flush()
drm.Close()
End Sub