CTL.Common/Utils.cs
(开头部分) 49KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Web;
using System.Data;
namespace CTL.Common
{
/// <summary>
/// 工具类
/// </summary>
public class Utils
{
/// <summary>
/// 导出数据到Excel中
/// </summary>
/// <param name="exportData">要导出的数据</param>
/// <param name="fileName">文件名称</param>
public static void Export(StringBuilder exportData, string fileName)
{
StringBuilder sHtml = new StringBuilder();
string sheetName = "sheetName";
sHtml.Append("<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">");
sHtml.Append("<head>");
sHtml.Append("<!--[if gte mso 9]>");
sHtml.Append("<xml>");
sHtml.Append("<x:ExcelWorkbook>");
sHtml.Append("<x:ExcelWorksheets>");
sHtml.Append("<x:ExcelWorksheet>");
sHtml.Append("<x:Name>" + sheetName + "</x:Name>");
sHtml.Append("<x:WorksheetOptions>");
sHtml.Append("<x:Print>");
sHtml.Append("<x:ValidPrinterInfo />");
sHtml.Append("</x:Print>");
sHtml.Append("</x:WorksheetOptions>");
sHtml.Append("</x:ExcelWorksheet>");
sHtml.Append("</x:ExcelWorksheets>");
sHtml.Append("</x:ExcelWorkbook>");
sHtml.Append("</xml>");
sHtml.Append("<![endif]-->");
sHtml.Append("</head>");
sHtml.Append("<body>");
sHtml.Append(exportData);
sHtml.Append("</body>");
sHtml.Append("</html>");
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Charset = "UTF-8";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + Utils.GetRandomString(4, 4, "0123456789") + ".xls");
HttpContext.Current.Response.ContentType = "application/ms-excel";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
HttpContext.Current.Response.Write(sHtml);
HttpContext.Current.Response.End();
}
/// <summary>
后面还有 1456 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。