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;
}
}
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;
}
}