Repeater导出Excel如何 让Excel适应内容改变宽度
Repeater导出Excel如何 让Excel适应内容改变宽度
固定 也行 求教
[最优解释]
同学,不知道你有没有试过在response.write数据的时候给你所输出的内容定义一个样式呢?
response.Clear();
response.AddHeader("content-disposition", string.Format("attachment; filename={0}.xls", HttpUtility.UrlEncode(Encoding.UTF8.GetBytes(fileName))));
response.ContentType = "application/vnd.ms-excel";
response.Charset = "GB2312";
response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
response.Write(string.Format(@"<html><head><meta http-equiv=Content-Type content=""text/html; charset=GB2312""><style>{0}</style><script type='text/javascript'>{1}</script></head><body>", GetStyleForTravelLine(), GetJavascriptForTravelLine(OrderNumber, OutString)));
response.Write(content);
response.Write("");
response.Write("</body></html>");
response.Flush();
try
{
response.End();
}
catch { }