62,046
社区成员
发帖
与我相关
我的任务
分享
//Excel显示时会把编号:430221199001200000 显示为:4.30221E+17
//请问如何解决!!!!!!
//tablexml就是一个<table></table>标签,里面有些内容。现在问题是,
internal void RenderExcel(string tablexml)
{
// 确保有一个合法的输出文件名 上面 _fileName 定义的属性
if (_fileName == null || _fileName == string.Empty || !(_fileName.ToLower().EndsWith(".xls")))
_fileName = GetRandomFileName();
HttpResponse response = HttpContext.Current.Response;
response.Charset = "GB2312";
response.ContentEncoding = Encoding.GetEncoding("GB2312");
response.ContentType = "application/ms-excel/msword";
response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(_fileName));
CultureInfo cult = new CultureInfo("zh-CN", true);
StringWriter sw = new StringWriter(cult);
HtmlTextWriter writer = new HtmlTextWriter(sw);
writer.WriteLine("<meta http-equiv=\"Content-Type\" content=\"textss/html;charset=GB2312\">"+tablexml+"");
response.Write(sw.ToString());
response.End();
}
XXX.Attributes.Add("style", "vnd.ms-excel.numberformat: @;");