am trying to export data in mysql table to excel using spring hibernate. My excel export has no data after export. Your help will be appreciated. This is my code below.Thanks in advance
ExcelExport.java
@Override
protected void buildExcelDocument(Map<String, Object> model,
HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response)
throws Exception {
@SuppressWarnings("unchecked")
List<MOH> mohs = (List<MOH>) model.get("mohs");
HSSFSheet sheet = workbook.createSheet("MOH Form")
HSSFRow header = sheet.createRow(0);
header.createCell(0).setCellValue("ID");
header.getCell(0).setCellStyle(style);
header.createCell(1).setCellValue("Data");
header.getCell(1).setCellStyle(style);
int rowCount = 1;
for (MOH aBook : mohs) {
HSSFRow aRow = sheet.createRow(rowCount++);
aRow.createCell(0).setCellValue(aBook.getSurvey_id());
aRow.createCell(1).setCellValue(aBook.getName());
Controller.java
@RequestMapping(value = "/downloadExcel", method = RequestMethod.GET)
public ModelAndView downloadExcel() {
ModelAndView mav = new ModelAndView("showMOH");
List<MOH> mohs = new ArrayList<MOH>();
return new ModelAndView("excelView", "mohs", mohs);