2023年12月7日发(作者:)

解决导出为Excel时文件名乱码的问题。

以前代码:

public static void htmlToExcel(HttpContext context, string title, string html, string fileCss = "", string SheetName = "")

{

var Response = se;

string html1 = html;

tType = "application/force-download";

der("content-disposition", "attachment; filename=" + title + ".xls");

("");

("");

("");

if (fileCss != "")

{

string cssText = ;

StreamReader sr = new StreamReader(fileCss);

var line = ;

while ((line = ne()) != null)

{

cssText += line;

}

();

("");

}

(" ");

(html1);//HTML

();

();

}

  

public static void htmlToExcel(HttpContext context, string title, string html, string fileCss = "", string SheetName = "")

{

var Response = se;

string html1 = html;

tType = "application/force-download";

title = ode(title, oding("UTF-8"));

der("content-disposition", "attachment; filename=" + title + ".xls");

("");

("");

("");

if (fileCss != "")

{

string cssText = ;

StreamReader sr = new StreamReader(fileCss);

var line = ;

while ((line = ne()) != null)

{

cssText += line;

}

();

("");

}

(" ");

(html1);//HTML

();

();

}

  给文件名通过转码的方式进行导出。