asp.net导出excel的问题
VB.NET code:
private void ToExcel(Control ctl, string FileName)
{
HttpContext.Current.Response.Charset = "UTF-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
HttpContext.Current.Response.ContentType = "application/ms-excel";
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + "" + FileName);
ctl.Page.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}
导出为以上代码,一般使用也正常,但发现有时会出现乱码,昨天一个个测试发现导出这个人时,有乱码,查看.xls代码如下去掉“甫”字一切显示正常
求解决办法,或有其他能解决乱码的导出方法。
HTML code:
<table cellspacing="0" rules="all" bordercolor="Gainsboro" border="1" id="DataGrid1" style="border-color:Gainsboro;border-width:1px;border-style:solid;font-siz
相关问答:
前段时间碰到一道面试题如下:
test.aspx页面有如下代码:
Response.Write(Test.GetDate());
Test类如下:
public class Test
{
static string dt="";
public static s ......
<script type="text/javascript" src="js/Dialog.js"></script>
<script type="text/javascript">
function zOpenD()
{
va ......
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.WebControls
Namespace CBDAspNet.WebControls.HTML
''' <summary>
'' ......
function CheckOpwd(){//验证用户名
var pwd=document.all.txtOpwd;
var div1=document.getElementById("divPwd");
if (pwd.value=="")
{
......