办法就是利用Excel的特性
代码
<%@ Page language="c#" AutoEventWireup="true" %>
<script runat="server">
void Page_Load(object sender, System.EventArgs e)
{
string data1 = "000000001";
long data2 = 123456789123456789;
System.IO.StringWriter sw = new System.IO.StringWriter();
sw.WriteLine("原数字1\t转换后数字1\t原数字2\t转换数字2");
for(int i= 0;i<10;i++)
{
sw.WriteLine(data1 +"\t" + "=\"" + data1 + "\"\t" + data2 +"\t" + "=\"" + data2.ToString() + "\"");
}
sw.Close();
Response.Buffer= true;
Response.Charset="";
Response.AppendHeader("Content-Disposition","attachment;filename=aa.xls");
Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");//设置输出流为简体中文
Response.Write(sw);
Response.End();
}
</script>