Index: lams_central/src/java/org/lamsfoundation/lams/web/outcome/OutcomeController.java =================================================================== diff -u -r757ceb570a6d7b9ac11df60ef4de581848c79ba0 -rf13b8a48b9a1cfaee56a654ba751a9736616b726 --- lams_central/src/java/org/lamsfoundation/lams/web/outcome/OutcomeController.java (.../OutcomeController.java) (revision 757ceb570a6d7b9ac11df60ef4de581848c79ba0) +++ lams_central/src/java/org/lamsfoundation/lams/web/outcome/OutcomeController.java (.../OutcomeController.java) (revision f13b8a48b9a1cfaee56a654ba751a9736616b726) @@ -24,7 +24,6 @@ import java.util.Date; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -54,7 +53,7 @@ import org.lamsfoundation.lams.util.FileUtil; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.WebUtil; -import org.lamsfoundation.lams.util.excel.ExcelCell; +import org.lamsfoundation.lams.util.excel.ExcelSheet; import org.lamsfoundation.lams.util.excel.ExcelUtil; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -474,7 +473,7 @@ UserDTO user = getUserDTO(); securityService.isSysadmin(user.getUserID(), "export outcomes", true); - LinkedHashMap dataToExport = outcomeService.exportOutcomes(); + List sheets = outcomeService.exportOutcomes(); String fileName = "lams_outcomes.xls"; fileName = FileUtil.encodeFilenameForDownload(request, fileName); @@ -490,7 +489,7 @@ // Code to generate file and write file contents to response ServletOutputStream out = response.getOutputStream(); - ExcelUtil.createExcelXLS(out, dataToExport, messageService.getMessage("outcome.export.date"), true); + ExcelUtil.createExcel(out, sheets, messageService.getMessage("outcome.export.date"), true, false); } @RequestMapping("/outcomeImport") @@ -723,7 +722,7 @@ UserDTO user = getUserDTO(); securityService.isSysadmin(user.getUserID(), "export outcome scales", true); - LinkedHashMap dataToExport = outcomeService.exportScales(); + List sheets = outcomeService.exportScales(); String fileName = "lams_outcome_scales.xls"; fileName = FileUtil.encodeFilenameForDownload(request, fileName); @@ -739,7 +738,7 @@ // Code to generate file and write file contents to response ServletOutputStream out = response.getOutputStream(); - ExcelUtil.createExcelXLS(out, dataToExport, messageService.getMessage("outcome.export.date"), true); + ExcelUtil.createExcel(out, sheets, messageService.getMessage("outcome.export.date"), true, false); } @RequestMapping("/scaleImport") Index: lams_common/src/java/org/lamsfoundation/lams/outcome/service/IOutcomeService.java =================================================================== diff -u -r757ceb570a6d7b9ac11df60ef4de581848c79ba0 -rf13b8a48b9a1cfaee56a654ba751a9736616b726 --- lams_common/src/java/org/lamsfoundation/lams/outcome/service/IOutcomeService.java (.../IOutcomeService.java) (revision 757ceb570a6d7b9ac11df60ef4de581848c79ba0) +++ lams_common/src/java/org/lamsfoundation/lams/outcome/service/IOutcomeService.java (.../IOutcomeService.java) (revision f13b8a48b9a1cfaee56a654ba751a9736616b726) @@ -1,15 +1,14 @@ package org.lamsfoundation.lams.outcome.service; import java.io.IOException; -import java.util.LinkedHashMap; import java.util.List; import java.util.Set; import org.lamsfoundation.lams.outcome.Outcome; import org.lamsfoundation.lams.outcome.OutcomeMapping; import org.lamsfoundation.lams.outcome.OutcomeResult; import org.lamsfoundation.lams.outcome.OutcomeScale; -import org.lamsfoundation.lams.util.excel.ExcelCell; +import org.lamsfoundation.lams.util.excel.ExcelSheet; import org.springframework.web.multipart.MultipartFile; public interface IOutcomeService { @@ -36,9 +35,9 @@ void copyOutcomeMappings(Long sourceLessonId, Long sourceToolContentId, Long sourceItemId, Long targetLessonId, Long targetToolContentId, Long targetItemId); - LinkedHashMap exportScales(); + List exportScales(); - LinkedHashMap exportOutcomes(); + List exportOutcomes(); int importScales(MultipartFile fileItem) throws IOException; Index: lams_common/src/java/org/lamsfoundation/lams/outcome/service/OutcomeService.java =================================================================== diff -u -r757ceb570a6d7b9ac11df60ef4de581848c79ba0 -rf13b8a48b9a1cfaee56a654ba751a9736616b726 --- lams_common/src/java/org/lamsfoundation/lams/outcome/service/OutcomeService.java (.../OutcomeService.java) (revision 757ceb570a6d7b9ac11df60ef4de581848c79ba0) +++ lams_common/src/java/org/lamsfoundation/lams/outcome/service/OutcomeService.java (.../OutcomeService.java) (revision f13b8a48b9a1cfaee56a654ba751a9736616b726) @@ -27,6 +27,8 @@ import org.lamsfoundation.lams.util.FileUtil; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.excel.ExcelCell; +import org.lamsfoundation.lams.util.excel.ExcelRow; +import org.lamsfoundation.lams.util.excel.ExcelSheet; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; import org.springframework.web.multipart.MultipartFile; @@ -102,59 +104,52 @@ } @Override - public LinkedHashMap exportScales() { - LinkedHashMap dataToExport = new LinkedHashMap(); + public List exportScales() { + List sheets = new LinkedList(); + ExcelSheet scalesSheet = new ExcelSheet(messageService.getMessage("scale.title")); + sheets.add(scalesSheet); - // The entire data list - List rowList = new LinkedList(); - ExcelCell[] row = new ExcelCell[4]; - row[0] = new ExcelCell(messageService.getMessage("outcome.manage.add.name"), true); - row[1] = new ExcelCell(messageService.getMessage("outcome.manage.add.code"), true); - row[2] = new ExcelCell(messageService.getMessage("outcome.manage.add.description"), true); - row[3] = new ExcelCell(messageService.getMessage("scale.manage.add.value"), true); - rowList.add(row); + ExcelRow headerRow = scalesSheet.initRow(); + headerRow.addCell(messageService.getMessage("outcome.manage.add.name"), true); + headerRow.addCell(messageService.getMessage("outcome.manage.add.code"), true); + headerRow.addCell(messageService.getMessage("outcome.manage.add.description"), true); + headerRow.addCell(messageService.getMessage("scale.manage.add.value"), true); List scales = getScales(null); for (OutcomeScale scale : scales) { - row = new ExcelCell[4]; - row[0] = new ExcelCell(scale.getName(), false); - row[1] = new ExcelCell(scale.getCode(), false); - row[2] = new ExcelCell(scale.getDescription(), false); - row[3] = new ExcelCell(scale.getItemString(), false); - rowList.add(row); + ExcelRow scaleRow = scalesSheet.initRow(); + scaleRow.addCell(scale.getName()); + scaleRow.addCell(scale.getCode()); + scaleRow.addCell(scale.getDescription()); + scaleRow.addCell(scale.getItemString()); } - ExcelCell[][] data = rowList.toArray(new ExcelCell[][] {}); - dataToExport.put(messageService.getMessage("scale.title"), data); - return dataToExport; + return sheets; } @Override - public LinkedHashMap exportOutcomes() { - LinkedHashMap dataToExport = new LinkedHashMap(); + public List exportOutcomes() { + List sheets = new LinkedList(); + ExcelSheet outcomeSheet = new ExcelSheet(messageService.getMessage("index.outcome.manage")); + sheets.add(outcomeSheet); // The entire data list - List rowList = new LinkedList(); - ExcelCell[] row = new ExcelCell[4]; - row[0] = new ExcelCell(messageService.getMessage("outcome.manage.add.name"), true); - row[1] = new ExcelCell(messageService.getMessage("outcome.manage.add.code"), true); - row[2] = new ExcelCell(messageService.getMessage("outcome.manage.add.description"), true); - row[3] = new ExcelCell(messageService.getMessage("outcome.manage.add.scale"), true); - rowList.add(row); + ExcelRow headerRow = outcomeSheet.initRow(); + headerRow.addCell(messageService.getMessage("outcome.manage.add.name"), true); + headerRow.addCell(messageService.getMessage("outcome.manage.add.code"), true); + headerRow.addCell(messageService.getMessage("outcome.manage.add.description"), true); + headerRow.addCell(messageService.getMessage("outcome.manage.add.scale"), true); List outcomes = getOutcomes(null); for (Outcome outcome : outcomes) { - row = new ExcelCell[4]; - row[0] = new ExcelCell(outcome.getName(), false); - row[1] = new ExcelCell(outcome.getCode(), false); - row[2] = new ExcelCell(outcome.getDescription(), false); - row[3] = new ExcelCell(outcome.getScale().getCode(), false); - rowList.add(row); + ExcelRow outcomeRow = outcomeSheet.initRow(); + outcomeRow.addCell(outcome.getName()); + outcomeRow.addCell(outcome.getCode()); + outcomeRow.addCell(outcome.getDescription()); + outcomeRow.addCell(outcome.getScale().getCode()); } - ExcelCell[][] data = rowList.toArray(new ExcelCell[][] {}); - dataToExport.put(messageService.getMessage("index.outcome.manage"), data); - return dataToExport; + return sheets; } @Override Index: lams_common/src/java/org/lamsfoundation/lams/util/excel/ExcelRow.java =================================================================== diff -u -rd471fb4d4ad60b6568b9f3cb4ec9cd82c6fbe495 -rf13b8a48b9a1cfaee56a654ba751a9736616b726 --- lams_common/src/java/org/lamsfoundation/lams/util/excel/ExcelRow.java (.../ExcelRow.java) (revision d471fb4d4ad60b6568b9f3cb4ec9cd82c6fbe495) +++ lams_common/src/java/org/lamsfoundation/lams/util/excel/ExcelRow.java (.../ExcelRow.java) (revision f13b8a48b9a1cfaee56a654ba751a9736616b726) @@ -11,6 +11,7 @@ * @author Andrey Balan */ public class ExcelRow { + private boolean isBold = false; private List cells = new ArrayList<>(); /** @@ -86,6 +87,14 @@ } } + public boolean isBold() { + return isBold; + } + + public void setBold(boolean isBold) { + this.isBold = isBold; + } + public List getCells() { return cells; } Index: lams_common/src/java/org/lamsfoundation/lams/util/excel/ExcelSheet.java =================================================================== diff -u -rcbf95a868252401757c61327b3d9a383119ff9b5 -rf13b8a48b9a1cfaee56a654ba751a9736616b726 --- lams_common/src/java/org/lamsfoundation/lams/util/excel/ExcelSheet.java (.../ExcelSheet.java) (revision cbf95a868252401757c61327b3d9a383119ff9b5) +++ lams_common/src/java/org/lamsfoundation/lams/util/excel/ExcelSheet.java (.../ExcelSheet.java) (revision f13b8a48b9a1cfaee56a654ba751a9736616b726) @@ -34,13 +34,18 @@ public ExcelRow getRow(int index) { return rows.get(index); } - - public ExcelRow initRow() { + + public ExcelRow initRow(boolean isBold) { ExcelRow row = new ExcelRow(); rows.add(row); + row.setBold(isBold); return row; } + public ExcelRow initRow() { + return initRow(false); + } + public void addRow(ExcelRow row) { rows.add(row); } Index: lams_common/src/java/org/lamsfoundation/lams/util/excel/ExcelUtil.java =================================================================== diff -u -rcbf95a868252401757c61327b3d9a383119ff9b5 -rf13b8a48b9a1cfaee56a654ba751a9736616b726 --- lams_common/src/java/org/lamsfoundation/lams/util/excel/ExcelUtil.java (.../ExcelUtil.java) (revision cbf95a868252401757c61327b3d9a383119ff9b5) +++ lams_common/src/java/org/lamsfoundation/lams/util/excel/ExcelUtil.java (.../ExcelUtil.java) (revision f13b8a48b9a1cfaee56a654ba751a9736616b726) @@ -86,17 +86,13 @@ public final static String DEFAULT_FONT_NAME = "Calibri-Regular"; - /** - * Create .xls file out of provided data and then write out it to an OutputStream. It should be saved with the .xls extension. - * Only use if you want to read the file back in again afterwards. - * - * Warning: The styling is untested with this option and may fail. If you want full styling look at createExcel() + * Create .xlsx file out of provided data and then write out it to an OutputStream. It will be saved with the .xlsx extension. * * @param out * output stream to which the file written; usually taken from HTTP response - * @param dataToExport - * array of data to print out; first index of array describes a row, second a column + * @param sheets + * list of sheets to print out * @param dateHeader * text describing current date; if NULL then no date is printed; if not NULL * then text is written out along with current date in the cell; the date is formatted according to @@ -105,14 +101,16 @@ * whether to display title (printed in the first (0,0) cell) * @throws IOException */ - public static void createExcelXLS(OutputStream out, LinkedHashMap dataToExport, - String dateHeader, boolean displaySheetTitle) throws IOException { - Workbook workbook = new HSSFWorkbook(); - ExcelUtil.create(workbook, out, dataToExport, dateHeader, displaySheetTitle); + public static void createExcel(OutputStream out, List sheets, String dateHeader, + boolean displaySheetTitle) throws IOException { + ExcelUtil.createExcel(out, sheets, dateHeader, displaySheetTitle, true); } - + /** - * Create .xlsx file out of provided data and then write out it to an OutputStream. It should be saved with the .xlsx extension. + * Creates Excel file based on the provided data and writes it out to an OutputStream. + * + * + * Warning: The styling is untested with this option and may fail. If you want full styling look at createExcel() * * @param out * output stream to which the file written; usually taken from HTTP response @@ -124,39 +122,33 @@ * {@link #EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT} * @param displaySheetTitle * whether to display title (printed in the first (0,0) cell) + * + * @param produceXlsxFile + * whether excel file should be of .xlsx or .xls format. Use .xls only if you want to read the file back + * in again afterwards. * @throws IOException */ - public static void createExcel(OutputStream out, LinkedHashMap dataToExport, - String dateHeader, boolean displaySheetTitle) throws IOException { + public static void createExcel(OutputStream out, List sheets, String dateHeader, + boolean displaySheetTitle, boolean produceXlsxFile) throws IOException { //set user time zone, which is required for outputting cells of time format HttpSession ss = SessionManager.getSession(); UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); TimeZone userTimeZone = user.getTimeZone(); LocaleUtil.setUserTimeZone(userTimeZone); - Workbook workbook = new SXSSFWorkbook(100); // keep 100 rows in memory, exceeding rows will be flushed to disk - ExcelUtil.create(workbook, out, dataToExport, dateHeader, displaySheetTitle); - } - - /** - * Temporary wrapper method. - */ - public static void createExcel(OutputStream out, List sheets, String dateHeader, - boolean displaySheetTitle) throws IOException { - LinkedHashMap dataToExport = new LinkedHashMap<>(); + //in case .xlsx is requested use SXSSFWorkbook.class (which keeps 100 rows in memory, exceeding rows will be flushed to disk) + Workbook workbook = produceXlsxFile ? new SXSSFWorkbook(100): new HSSFWorkbook(); + ExcelUtil.initStyles(workbook); + for (ExcelSheet sheet : sheets) { - List rowList = new LinkedList<>(); - for (ExcelRow row : sheet.getRows()) { - rowList.add(row.getCells().toArray(new ExcelCell[] {})); - } - dataToExport.put(sheet.getSheetName(), rowList.toArray(new ExcelCell[][] {})); + ExcelUtil.createSheet(workbook, sheet, dateHeader, displaySheetTitle); } - ExcelUtil.createExcel(out, dataToExport, dateHeader, displaySheetTitle); + + workbook.write(out); + out.close(); } - private static void create(Workbook workbook, OutputStream out, LinkedHashMap dataToExport, - String dateHeader, boolean displaySheetTitle) throws IOException { - + private static void initStyles(Workbook workbook) { Font defaultFont = workbook.createFont(); defaultFont.setFontName(DEFAULT_FONT_NAME); @@ -224,25 +216,13 @@ borderStyleBottomThinBoldFont = workbook.createCellStyle(); borderStyleBottomThinBoldFont.setBorderBottom(BorderStyle.THIN); borderStyleBottomThinBoldFont.setFont(boldFont); - - int i = 0; - for (String sheetName : dataToExport.keySet()) { - if (dataToExport.get(sheetName) != null) { - String sheetTitle = (displaySheetTitle) ? sheetName : null; - ExcelUtil.createSheet(workbook, sheetName, sheetTitle, i, dateHeader, dataToExport.get(sheetName)); - i++; - } - } - - workbook.write(out); - out.close(); } - public static void createSheet(Workbook workbook, String sheetName, String sheetTitle, int sheetIndex, - String dateHeader, ExcelCell[][] data) throws IOException { + private static void createSheet(Workbook workbook, ExcelSheet excelSheet, String dateHeader, boolean displaySheetTitle) + throws IOException { // Modify sheet name if required. It should contain only allowed letters and sheets are not allowed with // the same names (case insensitive) - sheetName = WorkbookUtil.createSafeSheetName(sheetName); + String sheetName = WorkbookUtil.createSafeSheetName(excelSheet.getSheetName()); while (workbook.getSheet(sheetName) != null) { sheetName += " "; } @@ -253,53 +233,55 @@ ((SXSSFSheet)sheet).trackAllColumnsForAutoSizing(); } - // Print title in bold, if needed - if (!StringUtils.isBlank(sheetTitle)) { - Row row = sheet.createRow(0); - ExcelUtil.createCell(new ExcelCell(sheetTitle, true), 0, row, workbook); + // Print title if requested + boolean isTitleToBePrinted = displaySheetTitle && StringUtils.isNotBlank(excelSheet.getSheetName()); + if (isTitleToBePrinted) { + ExcelRow excelRow = new ExcelRow(); + excelRow.addCell(excelSheet.getSheetName(), true); + ExcelUtil.createRow(excelRow, 0, sheet); } // Print current date, if needed - if (!StringUtils.isBlank(dateHeader)) { - Row row = sheet.createRow(1); - ExcelUtil.createCell(new ExcelCell(dateHeader, false), 0, row, workbook); - - ExcelUtil.createCell(new ExcelCell(FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT.format(new Date()), false), 1, row, workbook); + if (StringUtils.isNotBlank(dateHeader)) { + ExcelRow excelRow = new ExcelRow(); + excelRow.addCell(dateHeader); + excelRow.addCell(FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT.format(new Date())); + ExcelUtil.createRow(excelRow, 1, sheet); } - if (data != null) { - int maxColumnSize = 0; + int maxCellsNumber = 0; - // Print data - for (int rowIndex = 0; rowIndex < data.length; rowIndex++) { + // Print data + for (int rowIndex = 0; rowIndex < excelSheet.getRows().size(); rowIndex++) { + ExcelRow excelRow = excelSheet.getRow(rowIndex); - // in case there is a sheet title or dateHeader available start from 4th row - int rowIndexOffset = (StringUtils.isBlank(sheetTitle) && StringUtils.isBlank(dateHeader)) ? 0 : 4; + // in case there is a sheet title or dateHeader available start from 4th row + int rowIndexOffset = !isTitleToBePrinted && StringUtils.isBlank(dateHeader) ? 0 : 4; + ExcelUtil.createRow(excelRow, rowIndex + rowIndexOffset, sheet); - Row row = sheet.createRow(rowIndex + rowIndexOffset); - - int columnSize = data[rowIndex].length; - for (int columnIndex = 0; columnIndex < columnSize; columnIndex++) { - ExcelCell excelCell = data[rowIndex][columnIndex]; - ExcelUtil.createCell(excelCell, columnIndex, row, workbook); - } - - //calculate max column size - if (columnSize > maxColumnSize) { - maxColumnSize = columnSize; - } + //calculate max column size + int cellsNumber = excelRow.getCells().size(); + if (cellsNumber > maxCellsNumber) { + maxCellsNumber = cellsNumber; } + } - //autoSizeColumns - for (int i = 0; i < maxColumnSize; i++) { - sheet.autoSizeColumn(i); - } + //autoSizeColumns + for (int i = 0; i < maxCellsNumber; i++) { + sheet.autoSizeColumn(i); } } - public static void createCell(ExcelCell excelCell, int cellnum, Row row, Workbook workbook) { - if (excelCell != null) { - Cell cell = row.createCell(cellnum); + private static void createRow(ExcelRow excelRow, int rowIndex, Sheet sheet) { + Row row = sheet.createRow(rowIndex); + + int columnIndex = 0; + for (ExcelCell excelCell : excelRow.getCells()) { + if (excelCell == null) { + continue; + } + + Cell cell = row.createCell(columnIndex++); Object excelCellValue = excelCell.getCellValue(); //cast excelCell's value @@ -312,7 +294,7 @@ } else if (excelCellValue instanceof java.lang.Float) { cell.setCellValue((Float) excelCellValue); - + } else if (excelCellValue instanceof java.lang.Double) { cell.setCellValue((Double) excelCellValue); @@ -329,7 +311,7 @@ //figure out cell's style CellStyle cellStyle = defaultStyle; - if (excelCell.isBold()) { + if (excelCell.isBold() || excelRow.isBold()) { cellStyle = boldStyle; } if (excelCell.getColor() != null) { @@ -367,7 +349,7 @@ } break; case ExcelCell.BORDER_STYLE_RIGHT_THICK: - if (excelCell.isBold() ) { + if (excelCell.isBold()) { cellStyle = borderStyleRightThickBoldFont; } else { cellStyle = borderStyleRightThick; @@ -385,26 +367,26 @@ } } cell.setCellStyle(cellStyle); - + //set data format if (excelCellValue != null && (excelCellValue instanceof java.lang.Integer || excelCellValue instanceof java.lang.Long)) { CellUtil.setCellStyleProperty(cell, CellUtil.DATA_FORMAT, numberFormat); - + } else if (excelCellValue != null && (excelCellValue instanceof java.lang.Float || excelCellValue instanceof java.lang.Double)) { CellUtil.setCellStyleProperty(cell, CellUtil.DATA_FORMAT, floatFormat); - + } else if (excelCell.getDataFormat() == ExcelCell.CELL_FORMAT_DATE) { CellUtil.setCellStyleProperty(cell, CellUtil.DATA_FORMAT, dateFormat); - + } else if (excelCell.getDataFormat() == ExcelCell.CELL_FORMAT_TIME) { CellUtil.setCellStyleProperty(cell, CellUtil.DATA_FORMAT, timeFormat); - } + } if (excelCell.getDataFormat() == ExcelCell.CELL_FORMAT_PERCENTAGE) { CellUtil.setCellStyleProperty(cell, CellUtil.DATA_FORMAT, percentageFormat); } - + //set alignment if (excelCell.getAlignment() != 0) { switch (excelCell.getAlignment()) { Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GroupingUploadAJAXController.java =================================================================== diff -u -r757ceb570a6d7b9ac11df60ef4de581848c79ba0 -rf13b8a48b9a1cfaee56a654ba751a9736616b726 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GroupingUploadAJAXController.java (.../GroupingUploadAJAXController.java) (revision 757ceb570a6d7b9ac11df60ef4de581848c79ba0) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GroupingUploadAJAXController.java (.../GroupingUploadAJAXController.java) (revision f13b8a48b9a1cfaee56a654ba751a9736616b726) @@ -31,7 +31,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -71,7 +70,8 @@ import org.lamsfoundation.lams.util.FileUtil; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.WebUtil; -import org.lamsfoundation.lams.util.excel.ExcelCell; +import org.lamsfoundation.lams.util.excel.ExcelRow; +import org.lamsfoundation.lams.util.excel.ExcelSheet; import org.lamsfoundation.lams.util.excel.ExcelUtil; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -110,8 +110,8 @@ /** * Get the spreadsheet file containing list of the current users, ready for uploading with groups. If lesson - * supplied, - * list lesson users, otherwise list organisation users (course grouping screen has just the organisation). + * supplied, list lesson users, otherwise list organisation users (course grouping screen has just the + * organisation). * * @throws Exception */ @@ -151,16 +151,15 @@ .append(" ").append(lessonOrOrganisationName).append(".xls").toString().replaceAll(" ", "-"); fileName = FileUtil.encodeFilenameForDownload(request, fileName); - LinkedHashMap dataToExport = null; - + List sheets; if (lesson != null) { Set learners = lesson.getLessonClass().getLearners(); // check for any groups already exist in this grouping Long activityId = WebUtil.readLongParam(request, AttributeNames.PARAM_ACTIVITY_ID); Activity activity = monitoringService.getActivityById(activityId); Grouping grouping = activity.isChosenBranchingActivity() ? activity.getGrouping() : ((GroupingActivity) activity).getCreateGrouping(); - dataToExport = exportLearnersForGrouping(learners, grouping.getGroups(), null); + sheets = exportLearnersForGrouping(learners, grouping.getGroups(), null); } else { Long groupingId = WebUtil.readLongParam(request, "groupingId", true); @@ -174,7 +173,7 @@ } Vector learners = userManagementService.getUsersFromOrganisationByRole(organisationId, Role.LEARNER, true); - dataToExport = exportLearnersForGrouping(learners, null, groups); + sheets = exportLearnersForGrouping(learners, null, groups); } // set cookie that will tell JS script that export has been finished @@ -186,29 +185,28 @@ response.setContentType("application/x-download"); response.setHeader("Content-Disposition", "attachment;filename=" + fileName); ServletOutputStream out = response.getOutputStream(); - ExcelUtil.createExcelXLS(out, dataToExport, null, false); + ExcelUtil.createExcel(out, sheets, null, false, false); } - private LinkedHashMap exportLearnersForGrouping(Collection learners, Set groups, + private List exportLearnersForGrouping(Collection learners, Set groups, Set orgGroups) { + List sheets = new LinkedList(); + ExcelSheet excelSheet = new ExcelSheet(messageService.getMessage("label.course.groups.prefix")); + sheets.add(excelSheet); - List rowList = new LinkedList<>(); - int numberOfColumns = 4; + ExcelRow titleRow = excelSheet.initRow(); + titleRow.addCell(messageService.getMessage("spreadsheet.column.login")); + titleRow.addCell(messageService.getMessage("spreadsheet.column.firstname")); + titleRow.addCell(messageService.getMessage("spreadsheet.column.lastname")); + titleRow.addCell(messageService.getMessage("spreadsheet.column.groupname")); - ExcelCell[] title = new ExcelCell[numberOfColumns]; - title[0] = new ExcelCell(messageService.getMessage("spreadsheet.column.login"), false); - title[1] = new ExcelCell(messageService.getMessage("spreadsheet.column.firstname"), false); - title[2] = new ExcelCell(messageService.getMessage("spreadsheet.column.lastname"), false); - title[3] = new ExcelCell(messageService.getMessage("spreadsheet.column.groupname"), false); - rowList.add(title); - if (groups != null) { List groupList = new LinkedList<>(groups); Collections.sort(groupList, new GroupComparator()); for (Group group : groupList) { String groupName = group.getGroupName(); for (User groupUser : group.getUsers()) { - rowList.add(generateUserRow(numberOfColumns, groupName, groupUser)); + generateUserRow(groupName, groupUser, excelSheet); learners.remove(groupUser); } } @@ -219,30 +217,26 @@ for (OrganisationGroup group : groupList) { String groupName = group.getName(); for (User groupUser : group.getUsers()) { - rowList.add(generateUserRow(numberOfColumns, groupName, groupUser)); + generateUserRow(groupName, groupUser, excelSheet); learners.remove(groupUser); } } } // all the remaining users are unassigned to any group for (User unassignedUser : learners) { - rowList.add(generateUserRow(numberOfColumns, null, unassignedUser)); + generateUserRow(null, unassignedUser, excelSheet); } - ExcelCell[][] summaryData = rowList.toArray(new ExcelCell[][] {}); - LinkedHashMap dataToExport = new LinkedHashMap<>(); - dataToExport.put(messageService.getMessage("label.course.groups.prefix"), summaryData); - return dataToExport; + return sheets; } - private ExcelCell[] generateUserRow(int numberOfColumns, String groupName, User groupUser) { - ExcelCell[] userRow = new ExcelCell[numberOfColumns]; - userRow[0] = new ExcelCell(groupUser.getLogin(), false); - userRow[1] = new ExcelCell(groupUser.getFirstName(), false); - userRow[2] = new ExcelCell(groupUser.getLastName(), false); - userRow[3] = new ExcelCell(groupName, false); - return userRow; + private void generateUserRow(String groupName, User groupUser, ExcelSheet excelSheet) { + ExcelRow userRow = excelSheet.initRow(); + userRow.addCell(groupUser.getLogin()); + userRow.addCell(groupUser.getFirstName()); + userRow.addCell(groupUser.getLastName()); + userRow.addCell(groupName); } /** Index: lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/service/IPeerreviewService.java =================================================================== diff -u -r757ceb570a6d7b9ac11df60ef4de581848c79ba0 -rf13b8a48b9a1cfaee56a654ba751a9736616b726 --- lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/service/IPeerreviewService.java (.../IPeerreviewService.java) (revision 757ceb570a6d7b9ac11df60ef4de581848c79ba0) +++ lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/service/IPeerreviewService.java (.../IPeerreviewService.java) (revision f13b8a48b9a1cfaee56a654ba751a9736616b726) @@ -24,7 +24,6 @@ package org.lamsfoundation.lams.tool.peerreview.service; import java.util.Collection; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -39,7 +38,7 @@ import org.lamsfoundation.lams.tool.peerreview.model.PeerreviewSession; import org.lamsfoundation.lams.tool.peerreview.model.PeerreviewUser; import org.lamsfoundation.lams.tool.service.ICommonToolService; -import org.lamsfoundation.lams.util.excel.ExcelCell; +import org.lamsfoundation.lams.util.excel.ExcelSheet; import com.fasterxml.jackson.databind.node.ArrayNode; @@ -315,7 +314,7 @@ int emailReportToUser(Long toolContentId, Long sessionId, Long userId, String emailReportToUser); /** Spreadsheet */ - LinkedHashMap exportTeamReportSpreadsheet(Long toolContentId); + List exportTeamReportSpreadsheet(Long toolContentId); int getCountItemsRatedByUserByCriteria(final Long criteriaId, final Integer userId); Index: lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/service/PeerreviewServiceImpl.java =================================================================== diff -u -r20aa6cbca9fc96d341080e6ad39f82593443f792 -rf13b8a48b9a1cfaee56a654ba751a9736616b726 --- lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/service/PeerreviewServiceImpl.java (.../PeerreviewServiceImpl.java) (revision 20aa6cbca9fc96d341080e6ad39f82593443f792) +++ lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/service/PeerreviewServiceImpl.java (.../PeerreviewServiceImpl.java) (revision f13b8a48b9a1cfaee56a654ba751a9736616b726) @@ -83,6 +83,7 @@ import org.lamsfoundation.lams.util.JsonUtil; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.excel.ExcelCell; +import org.lamsfoundation.lams.util.excel.ExcelSheet; import org.springframework.web.util.HtmlUtils; import com.fasterxml.jackson.databind.node.ArrayNode; @@ -499,7 +500,7 @@ } @Override - public LinkedHashMap exportTeamReportSpreadsheet(Long toolContentId) { + public List exportTeamReportSpreadsheet(Long toolContentId) { Peerreview peerreview = peerreviewDao.getByContentId(toolContentId); if (peerreview == null) { @@ -509,7 +510,6 @@ return new SpreadsheetBuilder(peerreview, ratingService, peerreviewSessionDao, peerreviewUserDao, this) .generateTeamReport(); - } @Override Index: lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/util/SpreadsheetBuilder.java =================================================================== diff -u -r757ceb570a6d7b9ac11df60ef4de581848c79ba0 -rf13b8a48b9a1cfaee56a654ba751a9736616b726 --- lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/util/SpreadsheetBuilder.java (.../SpreadsheetBuilder.java) (revision 757ceb570a6d7b9ac11df60ef4de581848c79ba0) +++ lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/util/SpreadsheetBuilder.java (.../SpreadsheetBuilder.java) (revision f13b8a48b9a1cfaee56a654ba751a9736616b726) @@ -4,7 +4,6 @@ import java.math.BigInteger; import java.math.RoundingMode; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -23,6 +22,8 @@ import org.lamsfoundation.lams.tool.peerreview.model.PeerreviewUser; import org.lamsfoundation.lams.tool.peerreview.service.IPeerreviewService; import org.lamsfoundation.lams.util.excel.ExcelCell; +import org.lamsfoundation.lams.util.excel.ExcelRow; +import org.lamsfoundation.lams.util.excel.ExcelSheet; import org.springframework.util.StringUtils; /** Creates a Spreadsheet that reports the averages, with each team/group shown on a separate worksheet. @@ -31,26 +32,15 @@ * Has a empty Mark column so that the teacher can add a manual mark if they want. */ public class SpreadsheetBuilder { - - private static final ExcelCell[] EMPTY_ROW = new ExcelCell[4]; - private Peerreview peerreview; private IRatingService ratingService; private List criterias; private PeerreviewSessionDAO peerreviewSessionDao; private PeerreviewUserDAO peerreviewUserDao; private IPeerreviewService service; - private LinkedHashMap dataToExport; + private List sheets; - // processing details set up when header is created, then used for each session - private ExcelCell[] titleRow; - private int countNonCommentCriteria = 0; - private int fullColumnCount = 0; - private int averageColumnIndex = 0; - private Map criteriaOffset; - - public SpreadsheetBuilder(Peerreview peerreview, IRatingService ratingService, PeerreviewSessionDAO peerreviewSessionDao, PeerreviewUserDAO peerreviewUserDao, IPeerreviewService service) { this.peerreview = peerreview; @@ -60,164 +50,169 @@ this.service = service; } - public LinkedHashMap generateTeamReport() { - + public List generateTeamReport() { // this one is guaranteed to give a consistent order over peerreview.getRatingCriterias() criterias = ratingService.getCriteriasByToolContentId(peerreview.getContentId()); + sheets = new LinkedList(); - dataToExport = new LinkedHashMap(); - - titleRow = generateWorksheetHeading(criterias); - List sessions = peerreviewSessionDao.getByContentId(peerreview.getContentId()); for (PeerreviewSession session : sessions) { - List rowList = generateTeamWorksheet(session); - ExcelCell[][] worksheetData = rowList.toArray(new ExcelCell[][] {}); - dataToExport.put(session.getSessionName(), worksheetData); + generateTeamSheet(session); } - - return dataToExport; + return sheets; } - private List generateTeamWorksheet(PeerreviewSession session) { + private void generateTeamSheet(PeerreviewSession session) { + ExcelSheet sessionSheet = new ExcelSheet(session.getSessionName()); + sheets.add(sessionSheet); - List rowList = new LinkedList(); - rowList.add(titleRow); + //Title row + ExcelRow titleRow = sessionSheet.initRow(); + titleRow.addCell(service.getLocalisedMessage("label.learner", null), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); + Map criteriaIndexMap = new HashMap(); + int countNonCommentCriteria = 0; + for ( RatingCriteria criteria : criterias ) { + if ( ! criteria.isCommentRating() ) { + titleRow.addCell(criteria.getTitle(), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); + criteriaIndexMap.put(criteria.getRatingCriteriaId(), countNonCommentCriteria); + countNonCommentCriteria++; + } + } + titleRow.addCell(service.getLocalisedMessage("label.average", null), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); + titleRow.addCell(service.getLocalisedMessage("label.spa.factor", null), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); + titleRow.addCell(service.getLocalisedMessage("label.total.group.mark", null), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); + titleRow.addCell(service.getLocalisedMessage("label.individual.mark", null), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); List users = peerreviewUserDao.getBySessionID(session.getSessionId()); Map userNames = new TreeMap(); for (PeerreviewUser user : users) { userNames.put(user.getUserId(), StringEscapeUtils.escapeCsv(user.getFirstName() + " " + user.getLastName())); } - - Map userRowMap = new HashMap(); - ExcelCell[] userRow = new ExcelCell[2]; - userRow[0] = new ExcelCell(service.getLocalisedMessage("label.number.of.team.members", null), true); - userRow[1] = new ExcelCell(users.size(), IndexedColors.YELLOW); - rowList.add(userRow); + ExcelRow numberOfTeamsRow = sessionSheet.initRow(); + numberOfTeamsRow.addCell(service.getLocalisedMessage("label.number.of.team.members", null), true); + numberOfTeamsRow.addCell(users.size(), IndexedColors.YELLOW); + sessionSheet.addEmptyRow(); - rowList.add(EMPTY_ROW); - // uses same index as the user row, so allow for the name in the first column Double[] criteriaMarkSum = new Double[countNonCommentCriteria+1]; Integer[] criteriaMarkCount = new Integer[countNonCommentCriteria+1]; - for (int index = 1; index < criteriaMarkSum.length; index++) { - criteriaMarkSum[index] = 0D; - criteriaMarkCount[index] = 0; + for (int i = 0; i < criteriaMarkSum.length-1; i++) { + criteriaMarkSum[i] = 0D; + criteriaMarkCount[i] = 0; } + Map userRowMap = new HashMap(); // Process all the criterias and build up rows for each rated user. Store in temporary map. List ratingDtos = service.getRatingCriteriaDtos(session.getPeerreview().getContentId(), session.getSessionId(), userNames.keySet(), true, -1L); for (ItemRatingDTO ratingDto : ratingDtos) { Double userMarkSum = 0D; - userRow = new ExcelCell[fullColumnCount]; - - for (ItemRatingCriteriaDTO cDto : ratingDto.getCriteriaDtos()) { - if (cDto.getAverageRatingAsNumber() != null && ! cDto.getAverageRatingAsNumber().equals(0)) { - Integer criteriaIndex = criteriaOffset.get(cDto.getRatingCriteria().getRatingCriteriaId()); - double db = cDto.getAverageRatingAsNumber().doubleValue(); - userRow[criteriaIndex] = new ExcelCell(roundTo2Places(db), false); + double[] userRowData = new double[countNonCommentCriteria]; + for (ItemRatingCriteriaDTO itemRatingCriteriaDTO : ratingDto.getCriteriaDtos()) { + if (itemRatingCriteriaDTO.getAverageRatingAsNumber() != null + && !itemRatingCriteriaDTO.getAverageRatingAsNumber().equals(0)) { + Integer criteriaIndex = criteriaIndexMap + .get(itemRatingCriteriaDTO.getRatingCriteria().getRatingCriteriaId()); + double db = itemRatingCriteriaDTO.getAverageRatingAsNumber().doubleValue(); + userRowData[criteriaIndex] = roundTo2Places(db); criteriaMarkSum[criteriaIndex] += db; criteriaMarkCount[criteriaIndex] = criteriaMarkCount[criteriaIndex] + 1; userMarkSum += db; } } - userRow[averageColumnIndex] = new ExcelCell(countNonCommentCriteria > 0 ? roundTo2Places(userMarkSum / countNonCommentCriteria) : 0D, true); - userRowMap.put(ratingDto.getItemId(), userRow); + ExcelRow userRow = new ExcelRow(); + Long userId = ratingDto.getItemId(); + userRow.addCell(userNames.get(userId)); + for (double userRowDataIter : userRowData) { + userRow.addCell(userRowDataIter); + } + userRow.addCell(countNonCommentCriteria > 0 ? roundTo2Places(userMarkSum / countNonCommentCriteria) : 0D, true); + userRowMap.put(userId, userRow); } // calculate the group averages - ExcelCell[] avgRow = new ExcelCell[fullColumnCount]; - avgRow[0] = new ExcelCell(service.getLocalisedMessage("label.average", null), true); + ExcelRow avgRow = new ExcelRow(); + avgRow.addCell(service.getLocalisedMessage("label.average", null), true); Double averageMarkSum = 0D; - for (int index = 1; index < criteriaMarkSum.length; index++) { - if ( criteriaMarkCount[index] > 0 ) { - Double d = criteriaMarkSum[index] / criteriaMarkCount[index]; - avgRow[index] = new ExcelCell(roundTo2Places(d), true); + for (int i = 0; i < criteriaMarkSum.length-1; i++) { + if ( criteriaMarkCount[i] > 0 ) { + Double d = criteriaMarkSum[i] / criteriaMarkCount[i]; + avgRow.addCell(roundTo2Places(d), true); averageMarkSum += d; - } + } else { + avgRow.addEmptyCell(); + } } Double finalGroupAverage = countNonCommentCriteria > 0 ? roundTo2Places(averageMarkSum / countNonCommentCriteria) : 0D; - avgRow[averageColumnIndex] = new ExcelCell(finalGroupAverage, true); + avgRow.addCell(finalGroupAverage, true); // Combine rated rows with rows with users not yet rated, to make up complete list, and write out to rowList. for (PeerreviewUser user : users) { - userRow = userRowMap.get(user.getUserId()); + ExcelRow userRow = userRowMap.get(user.getUserId()); if (userRow == null) { - userRow = new ExcelCell[fullColumnCount]; + userRow = sessionSheet.initRow(); + userRow.addCell(userNames.get(user.getUserId())); + } else { - ExcelCell averageCell = userRow[averageColumnIndex]; - Double learnerAverage = (Double) averageCell.getCellValue(); + Double learnerAverage = (Double) userRow.getCell(userRow.getCells().size()-1); Double spa = countNonCommentCriteria > 0 ? roundTo2Places(learnerAverage / finalGroupAverage): 0D; - userRow[averageColumnIndex+1] = new ExcelCell(spa, true); - userRow[averageColumnIndex+2] = new ExcelCell("", IndexedColors.YELLOW); - userRow[averageColumnIndex+3] = new ExcelCell("", IndexedColors.GREEN); + userRow.addCell(spa, true); + userRow.addCell("", IndexedColors.YELLOW); + userRow.addCell("", IndexedColors.GREEN); + + sessionSheet.addRow(userRow); } - userRow[0] = new ExcelCell(userNames.get(user.getUserId()), false); - rowList.add(userRow); } // Learners marks done, write out the group average - rowList.add(avgRow); + sessionSheet.addRow(avgRow); // now do all the comments for ( RatingCriteria criteria : criterias ) { if ( criteria.isCommentsEnabled() ) { - rowList.add(EMPTY_ROW); - rowList.add(EMPTY_ROW); - userRow = new ExcelCell[1]; - userRow[0] = new ExcelCell(criteria.getTitle(), true); - rowList.add(userRow); + sessionSheet.addEmptyRow(); + sessionSheet.addEmptyRow(); + ExcelRow criteriaTitleRow = sessionSheet.initRow(); + criteriaTitleRow.addCell(criteria.getTitle(), true); if ( criteria.isHedgeStyleRating() ) { // just need the first entry as it is the same for everyone - the justification if ( users.size() > 0 ) { - generateUsersComments(session, rowList, userNames, criteria, users.get(0), false); + generateUsersComments(session, sessionSheet, userNames, criteria, users.get(0), false); } } else { for ( PeerreviewUser user : users ) { - generateUsersComments(session, rowList, userNames, criteria, user, true); + generateUsersComments(session, sessionSheet, userNames, criteria, user, true); } } } - } - - return rowList; + } } - private void generateUsersComments(PeerreviewSession session, List rowList, - Map userNames, RatingCriteria criteria, PeerreviewUser user, boolean showForName) { + private void generateUsersComments(PeerreviewSession session, ExcelSheet sessionSheet, Map userNames, + RatingCriteria criteria, PeerreviewUser user, boolean showForName) { + sessionSheet.addEmptyRow(); - List commentRowList = new LinkedList(); List comments = peerreviewUserDao.getDetailedRatingsComments(session.getPeerreview().getContentId(), session.getSessionId(), criteria.getRatingCriteriaId(), user.getUserId()); + boolean isUserNameRowPrinted = false; for (Object[] comment : comments) { if (comment[1] != null) { - ExcelCell[] commentRow = new ExcelCell[2]; - commentRow[0] = new ExcelCell(userNames.get(((BigInteger) comment[0]).longValue()), false); - commentRow[1] = new ExcelCell(StringUtils.replace((String) comment[1], "
", "\n"), false); - commentRowList.add(commentRow); - } - } + if (showForName && !isUserNameRowPrinted) { + ExcelRow userNameRow = sessionSheet.initRow(); + userNameRow.addCell(service.getLocalisedMessage("label.for.user", + new Object[] { userNames.get(user.getUserId()) })); + isUserNameRowPrinted = true; + } - if (commentRowList.size() > 0) { - - rowList.add(EMPTY_ROW); - - if (showForName) { - ExcelCell[] userRow = new ExcelCell[1]; - userRow[0] = new ExcelCell(service.getLocalisedMessage("label.for.user", - new Object[] { userNames.get(user.getUserId()) }), false); - rowList.add(userRow); + ExcelRow commentRow = sessionSheet.initRow(); + commentRow.addCell(userNames.get(((BigInteger) comment[0]).longValue())); + commentRow.addCell(StringUtils.replace((String) comment[1], "
", "\n")); } - - rowList.addAll(commentRowList); } - } private double roundTo2Places(double d) { @@ -228,30 +223,4 @@ bd = bd.setScale(2, RoundingMode.HALF_UP); return bd.doubleValue(); } - - private ExcelCell[] generateWorksheetHeading(List criterias) { - ExcelCell[] titleRow = new ExcelCell[criterias.size() + 5]; - titleRow[0] = new ExcelCell(service.getLocalisedMessage("label.learner", null), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); - int index = 1; - - criteriaOffset = new HashMap(); - - for ( RatingCriteria criteria : criterias ) { - if ( ! criteria.isCommentRating() ) { - titleRow[index] = new ExcelCell(criteria.getTitle(), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); - criteriaOffset.put(criteria.getRatingCriteriaId(), index); - countNonCommentCriteria++; - index++; - } - } - averageColumnIndex = index; - - titleRow[index++] = new ExcelCell(service.getLocalisedMessage("label.average", null), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); - titleRow[index++] = new ExcelCell(service.getLocalisedMessage("label.spa.factor", null), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); - titleRow[index++] = new ExcelCell(service.getLocalisedMessage("label.total.group.mark", null), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); - titleRow[index++] = new ExcelCell(service.getLocalisedMessage("label.individual.mark", null), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); - fullColumnCount = index; - - return titleRow; - } } Index: lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/web/controller/MonitoringController.java =================================================================== diff -u -rcbf95a868252401757c61327b3d9a383119ff9b5 -rf13b8a48b9a1cfaee56a654ba751a9736616b726 --- lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/web/controller/MonitoringController.java (.../MonitoringController.java) (revision cbf95a868252401757c61327b3d9a383119ff9b5) +++ lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/web/controller/MonitoringController.java (.../MonitoringController.java) (revision f13b8a48b9a1cfaee56a654ba751a9736616b726) @@ -27,7 +27,6 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.LinkedHashMap; import java.util.List; import java.util.TimeZone; @@ -48,7 +47,7 @@ import org.lamsfoundation.lams.util.FileUtil; import org.lamsfoundation.lams.util.JsonUtil; import org.lamsfoundation.lams.util.WebUtil; -import org.lamsfoundation.lams.util.excel.ExcelCell; +import org.lamsfoundation.lams.util.excel.ExcelSheet; import org.lamsfoundation.lams.util.excel.ExcelUtil; import org.lamsfoundation.lams.web.util.AttributeNames; import org.lamsfoundation.lams.web.util.SessionMap; @@ -584,15 +583,15 @@ response.setHeader("Content-Disposition", "attachment;filename=" + fileName); ServletOutputStream out = response.getOutputStream(); - LinkedHashMap dataToExport = service.exportTeamReportSpreadsheet(toolContentId); + List sheets = service.exportTeamReportSpreadsheet(toolContentId); // set cookie that will tell JS script that export has been finished String downloadTokenValue = WebUtil.readStrParam(request, "downloadTokenValue"); Cookie fileDownloadTokenCookie = new Cookie("fileDownloadToken", downloadTokenValue); fileDownloadTokenCookie.setPath("/"); response.addCookie(fileDownloadTokenCookie); - ExcelUtil.createExcel(out, dataToExport, "Exported on:", true); + ExcelUtil.createExcel(out, sheets, "Exported on:", true); } catch (IOException e) { log.error("exportTeamReportExcelSpreadsheet i/o error occured: " + e.getMessage(), e);