normalexcelconstants导出怎么设置底部
答案:5 悬赏:50 手机版
解决时间 2021-01-21 22:49
- 提问者网友:原来太熟悉了会陌生
- 2021-01-21 11:15
normalexcelconstants导出怎么设置底部
最佳答案
- 五星知识达人网友:野慌
- 2021-01-21 12:38
之前使用poi导出Excel表格,需要配置很多东西,也比较麻烦,这里使用poi的封装easypoi,可以快速配置,实现Excel或者word文件的导出。这里我们结合SpringMVC开发easypoi。 导入jar包 这里是springMVC和easypoi所需的jar包 主要是easypoi-base和easypoi-web,其它都是关联所需的jar包,我们需要commons-lang3.jar包
全部回答
- 1楼网友:煞尾
- 2021-01-21 15:27
spring mvc 集成
@RequestMapping(params = "exportXls")
public String exportXls(CourseEntity course,HttpServletRequest request,HttpServletResponse response
, DataGrid dataGrid,ModelMap map) {
List courses = this.courseService.getListByCriteriaQuery(cq,false);
map.put(NormalExcelConstants.FILE_NAME,"用户信息");
map.put(NormalExcelConstants.CLASS,CourseEntity.class);
map.put(NormalExcelConstants.PARAMS,new ExportParams("课程列表", "导出人:Jeecg",
"导出信息"));
map.put(NormalExcelConstants.DATA_LIST,courses);
return NormalExcelConstants.JEECG_EXCEL_VIEW;
}
@RequestMapping(params = "exportXls")
public String exportXls(CourseEntity course,HttpServletRequest request,HttpServletResponse response
, DataGrid dataGrid,ModelMap map) {
List
map.put(NormalExcelConstants.FILE_NAME,"用户信息");
map.put(NormalExcelConstants.CLASS,CourseEntity.class);
map.put(NormalExcelConstants.PARAMS,new ExportParams("课程列表", "导出人:Jeecg",
"导出信息"));
map.put(NormalExcelConstants.DATA_LIST,courses);
return NormalExcelConstants.JEECG_EXCEL_VIEW;
}
- 2楼网友:有你哪都是故乡
- 2021-01-21 15:05
之前使用poi导出Excel表格,需要配置很多东西,也比较麻烦,这里使用poi的封装easypoi,可以快速配置,实现Excel或者word文件的导出。这里我们结合SpringMVC开发easypoi。
导入jar包
这里是springMVC和easypoi所需的jar包
主要是easypoi-base和easypoi-web,其它都是关联所需的jar包,我们需要commons-lang3.jar包,开始使用commons-lang2.6版本会出现错误。
spring-servlet.xml配置
[html] view plain copy
class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="0">
[html] view plain copy
controller
[java] view plain copy
package com.mvc.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
import org.jeecgframework.poi.excel.entity.vo.MapExcelConstants;
import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping(value="/excel")
public class ExcelController {
@RequestMapping(value = "/export",method = {RequestMethod.POST,RequestMethod.GET})
public String export(HttpServletRequest request,HttpServletResponse response,ModelMap modelMap){
//标题
List entityList = new ArrayList();
//内容
List
导入jar包
这里是springMVC和easypoi所需的jar包
主要是easypoi-base和easypoi-web,其它都是关联所需的jar包,我们需要commons-lang3.jar包,开始使用commons-lang2.6版本会出现错误。
spring-servlet.xml配置
[html] view plain copy
[html] view plain copy
controller
[java] view plain copy
package com.mvc.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
import org.jeecgframework.poi.excel.entity.vo.MapExcelConstants;
import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping(value="/excel")
public class ExcelController {
@RequestMapping(value = "/export",method = {RequestMethod.POST,RequestMethod.GET})
public String export(HttpServletRequest request,HttpServletResponse response,ModelMap modelMap){
//标题
List
//内容
List
- 3楼网友:慢性怪人
- 2021-01-21 14:17
之前使用poi导出Excel表格,需要配置很多东西,也比较麻烦,这里使用poi的封装easypoi,可以快速配置,实现Excel或者word文件的导出。这里我们结合SpringMVC开发easypoi。
导入jar包
这里是springMVC和easypoi所需的jar包
主要是easypoi-base和easypoi-web,其它都是关联所需的jar包,我们需要commons-lang3.jar包,开始使用commons-lang2.6版本会出现错误。
spring-servlet.xml配置
[html] view plain copy
class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="0">
[html] view plain copy
controller
[java] view plain copy
package com.mvc.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
import org.jeecgframework.poi.excel.entity.vo.MapExcelConstants;
import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping(value="/excel")
public class ExcelController {
@RequestMapping(value = "/export",method = {RequestMethod.POST,RequestMethod.GET})
public String export(HttpServletRequest request,HttpServletResponse response,ModelMap modelMap){
//标题
List entityList = new ArrayList();
//内容
List> dataResult = new ArrayList>();
entityList.add(new ExcelExportEntity("表头1", "table1", 15));
entityList.add(new ExcelExportEntity("表头2", "table2", 25));
entityList.add(new ExcelExportEntity("表头3", "table3", 35));
for (int i = 0; i < 10; i++) {
Map map = new HashMap();
map.put("table1", "苹果"+i);
map.put("table2", "香蕉"+i);
map.put("table3", "鸭梨"+i);
dataResult.add(map);
}
modelMap.put(MapExcelConstants.ENTITY_LIST, entityList);
modelMap.put(MapExcelConstants.MAP_LIST, dataResult);
String fileName = "easypoi测试列表";
modelMap.put(MapExcelConstants.FILE_NAME, fileName);
modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("easypoi列表", "测试列表"));
return MapExcelConstants.JEECG_MAP_EXCEL_VIEW;
}
}
配置好表头,内容体,文件名就可以使用了
导入jar包
这里是springMVC和easypoi所需的jar包
主要是easypoi-base和easypoi-web,其它都是关联所需的jar包,我们需要commons-lang3.jar包,开始使用commons-lang2.6版本会出现错误。
spring-servlet.xml配置
[html] view plain copy
[html] view plain copy
controller
[java] view plain copy
package com.mvc.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
import org.jeecgframework.poi.excel.entity.vo.MapExcelConstants;
import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping(value="/excel")
public class ExcelController {
@RequestMapping(value = "/export",method = {RequestMethod.POST,RequestMethod.GET})
public String export(HttpServletRequest request,HttpServletResponse response,ModelMap modelMap){
//标题
List
//内容
List
entityList.add(new ExcelExportEntity("表头1", "table1", 15));
entityList.add(new ExcelExportEntity("表头2", "table2", 25));
entityList.add(new ExcelExportEntity("表头3", "table3", 35));
for (int i = 0; i < 10; i++) {
Map
map.put("table1", "苹果"+i);
map.put("table2", "香蕉"+i);
map.put("table3", "鸭梨"+i);
dataResult.add(map);
}
modelMap.put(MapExcelConstants.ENTITY_LIST, entityList);
modelMap.put(MapExcelConstants.MAP_LIST, dataResult);
String fileName = "easypoi测试列表";
modelMap.put(MapExcelConstants.FILE_NAME, fileName);
modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("easypoi列表", "测试列表"));
return MapExcelConstants.JEECG_MAP_EXCEL_VIEW;
}
}
配置好表头,内容体,文件名就可以使用了
- 4楼网友:北方的南先生
- 2021-01-21 12:48
之前使用poi导出Excel表格,需要配置很多东西,也比较麻烦,这里使用poi的封装easypoi,可以快速配置,实现Excel或者word文件的导出。这里我们结合SpringMVC开发easypoi。 导入jar包 这里是springMVC和easypoi所需的jar包 主要是easypoi-base和easypoi-web,其它都是关联所需的jar包,我们需要commons-lang3.jar包,开始使用commons-lang2.6版本会出现错误。 spring-servlet.xml配置 [html] view plain copy [html] view plain copy controller [java] view plain copy package com.mvc.controller; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity; import org.jeecgframework.poi.excel.entity.vo.MapExcelConstants; import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller @RequestMapping(value="/excel") public class ExcelController { @RequestMapping(value = "/export",method = {RequestMethod.POST,RequestMethod.GET}) public String export(HttpServletRequest request,HttpServletResponse response,ModelMap modelMap){ //标题 List entityList = new ArrayList(); //内容 List> dataResult = new ArrayList>(); entityList.add(new ExcelExportEntity("表头1", "table1", 15)); entityList.add(new ExcelExportEntity("表头2", "table2", 25)); entityList.add(new ExcelExportEntity("表头3", "table3", 35)); for (int i = 0; i < 10; i++) { Map map = new HashMap(); map.put("table1", "苹果"+i); map.put("table2", "香蕉"+i); map.put("table3", "鸭梨"+i); dataResult.add(map); } modelMap.put(MapExcelConstants.ENTITY_LIST, entityList); modelMap.put(MapExcelConstants.MAP_LIST, dataResult); String fileName = "easypoi测试列表"; modelMap.put(MapExcelConstants.FILE_NAME, fileName); modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("easypoi列表", "测试列表")); return MapExcelConstants.JEECG_MAP_EXCEL_VIEW; } } 配置好表头,内容体,文件名就可以使用了
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯