创建 xlx java

来源:互联网 发布:能听裂空小说软件 编辑:程序博客网 时间:2024/05/22 10:40
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


import javax.servlet.http.HttpServletResponse;


import net.sf.jxls.exception.ParsePropertyException;
import net.sf.jxls.transformer.XLSTransformer;


import org.apache.poi.openxml4j.exceptions.InvalidFormatException;


public class MakeXlsx {


// 模板地址 tempPath
// 真实导出路径 filePath


public static String toXls(List list, String tempPath, String filePath, HttpServletResponse response) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("root", list);


XLSTransformer transformer = new XLSTransformer();
try {
transformer.transformXLS(tempPath, map, filePath);
} catch (ParsePropertyException e1) {
e1.printStackTrace();
} catch (InvalidFormatException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
FilesUtils.downLoad(filePath, response);
return null;
}


}
1 0
原创粉丝点击