package cn.util.http;

import java.io.IOException;
import java.net.URLEncoder;

import javax.servlet.http.HttpServletResponse;

import cn.util.core.IsKit;

public class FileKit {

	/**
	 * 将文件输出到浏览器(导出)
	 * setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
	 */
	public static void prepareRespond_xlsx(String fileName, HttpServletResponse response) throws IOException
	{
		if(IsKit.isEmpty(fileName)) {
			fileName = "导出文件";
		}
		response.setContentType("application/vnd.ms-excel");
		response.setCharacterEncoding("utf-8");
		fileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");
		//response.setHeader("Content-disposition", "attachment;filename*=utf-8'zh_cn'" + fileName + ".xlsx");
		response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
	}
	
}
