Java實現動態的匯出Excel表功能--用form表單提交
前端程式碼:
1,
2,
3,這是用form表單提交!
4,
後端程式碼實現:
控制器
@PostMapping(value = “/ExcelExport”)
public void ExcelExport(HttpServletRequest request, String id, HttpServletResponse response) {
String token = request.getParameter("token");
String account = JwtUtil.getClaim(token, SecurityConsts.ACCOUNT);
String username = JsonUtil.stringKey(account, "username");
Date date = JwtUtil.getClaim(token).getExpiresAt();
Long realExpire = date.getTime() - System.currentTimeMillis();
if (realExpire < 1200000) {
} else {
String id_str = request.getParameter("id");
memberService.ExcelExport(request, id, response, excel_path);
}
FileOutput fileOutput = new FileOutput();
fileOutput.setUrlStr("d:/");
fileOutput.setFileName("黨員基礎資訊表.xls");
}
業務層
void ExcelExport(HttpServletRequest request, String id, HttpServletResponse response, String excel_path);
實現類
@Override
public void ExcelExport(HttpServletRequest request, String id, HttpServletResponse response, String excel_path) {
String excel_title[] = request.getParameterValues("excel_title");
try {
List<M_member_Vo_1> list_member = baseMapper.listMember(id);
List<ExcelExportEntity> colList = new ArrayList<>();
ExcelExportEntity colEntity = null;
for (int i = 0; i < excel_title.length; i++) {
String[] dy = excel_title[i].split(",");
colEntity = new ExcelExportEntity(dy[1], dy[0]);
colList.add(colEntity);
}
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
for (M_member_Vo_1 m_member_Vo : list_member) {
Map<String, Object> valMap = new HashMap<String, Object>();
valMap.put("member_name", m_member_Vo.getMember_name());
valMap.put("member_sex", m_member_Vo.getMember_sex());
valMap.put("member_birthday", m_member_Vo.getMember_birthday());
valMap.put("member_mobile", m_member_Vo.getMember_mobile());
valMap.put("member_card", m_member_Vo.getMember_card());
valMap.put("member_dw", m_member_Vo.getMember_dw());
valMap.put("member_derp", m_member_Vo.getMember_derp());
valMap.put("member_xzzw", m_member_Vo.getMember_xzzw());
list.add(valMap);
}
String fileName = "";
fileName = "黨員基本資訊表"+".xls";
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("黨員基礎資訊表", "黨員資訊"), colList,
list);
FileOutputStream fos = new FileOutputStream(excel_path + fileName);
workbook.write(fos);
fos.close();
FileUtil.downloadFile(excel_path, fileName, response);
} catch (Exception e) {
e.printStackTrace();
}
}
Mapper層
@Select("…")
List<M_member_Vo> listMember(String member_org);
Vo類:
本地配置Excel:
file.Excel.path=D:/
Linux配置:
#黨員基本檔案Excel下載位置----上傳到伺服器這個路徑必須是linux上所擁有的路徑!!!要不然下載不了Excel檔案!!!
file.Excel.path=/data
pom.xml-----忽略!!!加粗樣式
相關文章
- form表單提交方式ORM
- formly-form 動態表單ORM
- 前端匯出Excel之動態多級表頭前端Excel
- form表單提交注意事項ORM
- form表單按enter鍵自動提交的問題ORM
- 觸發form表單自動提交的方式有哪些?ORM
- Java之POI操作Excel表-匯入匯出JavaExcel
- 用phpmailer實現網頁表單提交傳送郵件功能PHPAI網頁
- 【react】實現動態表單中巢狀動態表單React巢狀
- SpringBoot實現Excel匯入匯出,效能爆表,用起來夠優雅!Spring BootExcel
- Form 表單提交知識的總結(全)ORM
- 前端實現Excel匯入和匯出功能前端Excel
- Java匯出Pdf格式表單Java
- vue中怎麼動態生成form表單VueORM
- iOS 使用form表單形式提交post請求iOSORM
- Vue+Element+JS動態生成form表單實現新增和刪除操作VueJSORM
- 前端頁面上實現表單提交檔案上傳功能前端
- 仿 ElmentUI 實現一個 Form 表單UIORM
- 實現動態表單的一種思路
- Excel模板匯出之動態匯出Excel
- Dcat Admin實現簡單的excel匯入功能Excel
- Java高階特性-註解:註解實現Excel匯出功能JavaExcel
- Java Servlet 實現合併多單元格匯出ExcelJavaServletExcel
- vxe-form table 實現摺疊表單ORM
- POI的使用及匯出excel報表Excel
- EasyExcel資料匯出實現、動態表頭生成、SpringBoot3框架ExcelSpring Boot框架
- Vue通過Blob物件實現匯出Excel功能Vue物件Excel
- java 表單避免重複提交?Java
- 表單form方式ORM
- 清空form表單ORM
- vxe-form table 表單實現簡歷模板ORM
- 提交表單
- 簡單介紹v-for中動態校驗el-form表單項的實踐ORM
- vue 專案中 實現列表的匯出excel表格的功能VueExcel
- Vue資料驅動表單渲染,輕鬆搞定form表單VueORM
- Laravel-admin 表單提交兩級聯動功能編寫Laravel
- 使用LocalStorage實現Form表單內容本地儲存ORM
- form表單的簡單介紹ORM