参考博客:https://blog.csdn.net/youzhouliu/article/details/52038889
本次在项目中遇到下载excel文件,用excel打开,是乱码,用notepad或者editplus打开是正常的,代码如下:
此为csv文件下载工具类示例:
public static final String DBS_INSTRUCTION_FILE_SEPERATOR = “,”;
public class DownloadCSVUtil {
public Response downloadCSV(String fileName, List titleList, List columnList) {
DownloadProvider provider = new DownloadProvider();
provider.download(buildDownLoadContent(titleList, columnList), ConstantsHelper.CHARSET_UTF8);
return Response.ok(provider, MediaType.APPLICATION_OCTET_STREAM_TYPE).header(
“Content-Disposition”, String.format(“attachment; filename=%s.csv”, fileName)).build();
}
private String buildDownLoadContent(List ti
JAVA以UTF-8导出CSV文件,用excel打开产生乱码的解决方法
最新推荐文章于 2023-12-15 15:51:27 发布