Index: lams_build/3rdParty.userlibraries =================================================================== diff -u -re2e2aa63f31be07287637a2bec159d1574c0ba2c -r941922b2ef901dad643b18f6a349b156b5a822ea --- lams_build/3rdParty.userlibraries (.../3rdParty.userlibraries) (revision e2e2aa63f31be07287637a2bec159d1574c0ba2c) +++ lams_build/3rdParty.userlibraries (.../3rdParty.userlibraries) (revision 941922b2ef901dad643b18f6a349b156b5a822ea) @@ -1,6 +1,10 @@ + + + + @@ -25,7 +29,6 @@ - Index: lams_build/build.xml =================================================================== diff -u -re82bb496f160632bcc8263825a38982ce8397c0e -r941922b2ef901dad643b18f6a349b156b5a822ea --- lams_build/build.xml (.../build.xml) (revision e82bb496f160632bcc8263825a38982ce8397c0e) +++ lams_build/build.xml (.../build.xml) (revision 941922b2ef901dad643b18f6a349b156b5a822ea) @@ -113,6 +113,7 @@ + @@ -123,7 +124,6 @@ - Index: lams_build/lib/apache-poi/poi-3.8-beta4-20110812.jar =================================================================== diff -u Binary files differ Index: lams_build/lib/apache-poi/poi-ooxml-3.8-beta4-20110812.jar =================================================================== diff -u Binary files differ Index: lams_build/lib/apache-poi/poi-ooxml-schemas-3.8-beta4-20110812.jar =================================================================== diff -u Binary files differ Index: lams_build/lib/apache-poi/xmlbeans-2.4.0.jar =================================================================== diff -u Binary files differ Index: lams_build/lib/jakarta-poi/poi-2.5.1-final-20040804.jar =================================================================== diff -u -rb11fdf8e6de8f399b37b5382808063fd323d2958 -r941922b2ef901dad643b18f6a349b156b5a822ea Binary files differ Index: lams_build/liblist.txt =================================================================== diff -u -re2e2aa63f31be07287637a2bec159d1574c0ba2c -r941922b2ef901dad643b18f6a349b156b5a822ea --- lams_build/liblist.txt (.../liblist.txt) (revision e2e2aa63f31be07287637a2bec159d1574c0ba2c) +++ lams_build/liblist.txt (.../liblist.txt) (revision 941922b2ef901dad643b18f6a349b156b5a822ea) @@ -2,6 +2,11 @@ Folder Library Version License Vendor Description +apache-poi poi-3.8-beta4-20110812.jar 3.8-beta4 Apache License 2.0 Apache the Java API for Microsoft Documents + poi-ooxml-3.8-beta4-20110812.jar + poi-ooxml-schemas-3.8-beta4-20110812.jar + xmlbeans-2.4.0.jar + aspirin activation-1.1.1.jar aspirin.jar 0.8.03 Apache 1.1 license embeddable send-only SMTP server commons-pool-1.5.1.jar Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/util/GradebookUtil.java =================================================================== diff -u -r2f21856ec2ab85b47c93cfcc3fa2c8769be65077 -r941922b2ef901dad643b18f6a349b156b5a822ea --- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/util/GradebookUtil.java (.../GradebookUtil.java) (revision 2f21856ec2ab85b47c93cfcc3fa2c8769be65077) +++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/util/GradebookUtil.java (.../GradebookUtil.java) (revision 941922b2ef901dad643b18f6a349b156b5a822ea) @@ -44,22 +44,15 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -import jxl.CellView; -import jxl.JXLException; -import jxl.Workbook; -import jxl.format.Font; -import jxl.write.Label; -import jxl.write.Number; -import jxl.write.WritableCell; -import jxl.write.WritableCellFormat; -import jxl.write.WritableFont; -import jxl.write.WritableSheet; -import jxl.write.WritableWorkbook; -import jxl.write.WriteException; - import org.apache.commons.lang.StringUtils; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.lamsfoundation.lams.gradebook.dto.ExcelCell; -import org.lamsfoundation.lams.gradebook.dto.GBActivityGridRowDTO; import org.lamsfoundation.lams.gradebook.dto.GradebookGridRowDTO; import org.lamsfoundation.lams.gradebook.dto.comparators.GBAverageMarkComparator; import org.lamsfoundation.lams.gradebook.dto.comparators.GBAverageTimeTakenComparator; @@ -74,6 +67,8 @@ import org.w3c.dom.Element; public class GradebookUtil { + + private static CellStyle boldStyle; /** * Wrapper method for printing the xml for grid rows @@ -327,8 +322,13 @@ } public static void exportGradebookLessonToExcel(OutputStream out, String dateHeader, - LinkedHashMap dataToExport) throws IOException, JXLException { - WritableWorkbook workbook = Workbook.createWorkbook(out); + LinkedHashMap dataToExport) throws IOException { + Workbook workbook = new SXSSFWorkbook(100); // keep 100 rows in memory, exceeding rows will be flushed to disk + + boldStyle = workbook.createCellStyle(); + Font font = workbook.createFont(); + font.setBoldweight(Font.BOLDWEIGHT_BOLD); + boldStyle.setFont(font); int i = 0; for (String sheetName : dataToExport.keySet()) { @@ -338,72 +338,63 @@ } } - workbook.write(); - workbook.close(); + workbook.write(out); + out.close(); } - public static void createSheet(WritableWorkbook workbook, String sheetName, String sheetTitle, int sheetIndex, - String dateHeader, ExcelCell[][] data) throws IOException, JXLException { - WritableSheet sheet = workbook.createSheet(sheetName, sheetIndex); + public static void createSheet(Workbook workbook, String sheetName, String sheetTitle, int sheetIndex, + String dateHeader, ExcelCell[][] data) throws IOException { + Sheet sheet = workbook.createSheet(sheetName); + - // Prepare cell formatter used in all columns - CellView stretchedCellView = new CellView(); - stretchedCellView.setAutosize(true); - // Print title in bold, if needed if (!StringUtils.isBlank(sheetTitle)) { - sheet.addCell(createWritableCell(new ExcelCell(sheetTitle, true), 0, 0)); + Row row = sheet.createRow(0); + createCell(new ExcelCell(sheetTitle, true), 0, row); } // Print current date, if needed if (!StringUtils.isBlank(dateHeader)) { - sheet.addCell(new Label(0, 1, dateHeader)); + Row row = sheet.createRow(1); + createCell(new ExcelCell(dateHeader, false), 0, row); + SimpleDateFormat titleDateFormat = new SimpleDateFormat(FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT); - sheet.addCell(new Label(1, 1, titleDateFormat.format(new Date()))); + createCell(new ExcelCell(titleDateFormat.format(new Date()), false), 1, row); } if (data != null) { // Print data for (int rowIndex = 0; rowIndex < data.length; rowIndex++) { - int sheetRowIndex = rowIndex + 4; + Row row = sheet.createRow(rowIndex + 4); + for (int columnIndex = 0; columnIndex < data[rowIndex].length; columnIndex++) { ExcelCell excelCell = data[rowIndex][columnIndex]; - if (excelCell != null) { - sheet.addCell(createWritableCell(excelCell, columnIndex, sheetRowIndex)); - } + createCell(excelCell, columnIndex, row); } } } } - public static WritableCell createWritableCell(ExcelCell cell, int col, int row) throws WriteException { + public static void createCell(ExcelCell excelCell, int cellnum, Row row) { - if (cell != null) { - WritableCell writeableCell = null; - if (cell.getCellValue() != null && cell.getCellValue() instanceof Date) { + if (excelCell != null) { + Cell cell = row.createCell(cellnum); + if (excelCell.getCellValue() != null && excelCell.getCellValue() instanceof Date) { SimpleDateFormat cellDateFormat = new SimpleDateFormat(FileUtil.EXPORT_TO_SPREADSHEET_CELL_DATE_FORMAT); - writeableCell = new Label(col, row, cellDateFormat.format(cell.getCellValue())); - } else if (cell.getCellValue() != null && cell.getCellValue() instanceof java.lang.Double) { - writeableCell = new Number(col, row, (Double) cell.getCellValue()); - } else if (cell.getCellValue() != null && cell.getCellValue() instanceof java.lang.Long) { - writeableCell = new Number(col, row, ((Long) cell.getCellValue()).doubleValue()); - } else if (cell.getCellValue() != null) { - writeableCell = new Label(col, row, cell.getCellValue().toString()); - } else { - writeableCell = new Label(col, row, null); + cell.setCellValue(cellDateFormat.format(excelCell.getCellValue())); + } else if (excelCell.getCellValue() != null && excelCell.getCellValue() instanceof java.lang.Double) { + cell.setCellValue((Double) excelCell.getCellValue()); + } else if (excelCell.getCellValue() != null && excelCell.getCellValue() instanceof java.lang.Long) { + cell.setCellValue(((Long) excelCell.getCellValue()).doubleValue()); + } else if (excelCell.getCellValue() != null) { + cell.setCellValue(excelCell.getCellValue().toString()); } - if (cell.getIsBold() == Boolean.TRUE) { - Font font = writeableCell.getCellFormat().getFont(); - WritableFont labelFont = new WritableFont(font); - labelFont.setBoldStyle(WritableFont.BOLD); - WritableCellFormat labelCellFormat = new WritableCellFormat(labelFont); - writeableCell.setCellFormat(labelCellFormat); + if (excelCell.getIsBold()) { + cell.setCellStyle(boldStyle); } - return writeableCell; - } else { - return null; } } + } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/MonitoringAction.java =================================================================== diff -u -r0762d2ed47bda6daf6a2ae4eca9b3409b7c3b3ea -r941922b2ef901dad643b18f6a349b156b5a822ea --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/MonitoringAction.java (.../MonitoringAction.java) (revision 0762d2ed47bda6daf6a2ae4eca9b3409b7c3b3ea) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/MonitoringAction.java (.../MonitoringAction.java) (revision 941922b2ef901dad643b18f6a349b156b5a822ea) @@ -313,7 +313,7 @@ HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("Marks"); - sheet.setColumnWidth((short) 0, (short) 5000); + sheet.setColumnWidth(0, 5000); HSSFRow row = null; HSSFCell cell; Iterator iter = getTopicsSortedByAuthor(topicList).values().iterator(); @@ -331,54 +331,45 @@ if (first) { first = false; row = sheet.createRow(0); - cell = row.createCell((short) idx); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(idx); cell.setCellValue(getMessageService().getMessage("lable.topic.title.subject")); - sheet.setColumnWidth((short) idx, (short) 8000); + sheet.setColumnWidth(idx, 8000); ++idx; - cell = row.createCell((short) idx); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(idx); cell.setCellValue(getMessageService().getMessage("lable.topic.title.author")); - sheet.setColumnWidth((short) idx, (short) 8000); + sheet.setColumnWidth(idx, 8000); ++idx; - cell = row.createCell((short) idx); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(idx); cell.setCellValue(getMessageService().getMessage("label.download.marks.heading.date")); - sheet.setColumnWidth((short) idx, (short) 8000); + sheet.setColumnWidth(idx, 8000); ++idx; - cell = row.createCell((short) idx); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(idx); cell.setCellValue(getMessageService().getMessage("label.download.marks.heading.marks")); - sheet.setColumnWidth((short) idx, (short) 8000); + sheet.setColumnWidth(idx, 8000); ++idx; - cell = row.createCell((short) idx); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(idx); cell.setCellValue(getMessageService().getMessage("label.download.marks.heading.comments")); - sheet.setColumnWidth((short) idx, (short) 8000); + sheet.setColumnWidth(idx, 8000); ++idx; } ++fileCount; idx = 0; row = sheet.createRow(fileCount); - cell = row.createCell((short) idx++); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(idx++); cell.setCellValue(dto.getMessage().getSubject()); - cell = row.createCell((short) idx++); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(idx++); cell.setCellValue(dto.getAuthor()); - cell = row.createCell((short) idx++); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(idx++); cell.setCellValue(DateFormat.getInstance().format(dto.getMessage().getCreated())); - cell = row.createCell((short) idx++); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); - + cell = row.createCell(idx++); + if (dto.getMessage() != null && dto.getMessage().getReport() != null && dto.getMessage().getReport().getMark() != null) { cell.setCellValue(NumberUtil.formatLocalisedNumber(dto.getMessage().getReport().getMark(), @@ -387,8 +378,7 @@ cell.setCellValue(""); } - cell = row.createCell((short) idx++); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(idx++); if (dto.getMessage() != null && dto.getMessage().getReport() != null) { cell.setCellValue(dto.getMessage().getReport().getComment()); } else { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java =================================================================== diff -u -r3e5b36454b17cee648f9d02e0656e8e99c46e00e -r941922b2ef901dad643b18f6a349b156b5a822ea --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java (.../McMonitoringAction.java) (revision 3e5b36454b17cee648f9d02e0656e8e99c46e00e) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java (.../McMonitoringAction.java) (revision 941922b2ef901dad643b18f6a349b156b5a822ea) @@ -4744,7 +4744,7 @@ Iterator queIterator= mcContent.getMcQueContents().iterator(); Long mapIndex=new Long(1); - short idx = (short) 0; + int idx = 0; Iterator marksIterator = listMonitoredMarksContainerDTO.iterator(); @@ -4760,39 +4760,33 @@ row = sheet.createRow(idx++); - cell = row.createCell((short) 0); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(0); cell.setCellValue(messageService.getMessage("group.label")); - cell = row.createCell((short) 1); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(1); cell.setCellValue(currentSessionName); idx++; int count = 0; row = sheet.createRow(idx++); - cell = row.createCell((short) count++); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(count++); cell.setCellValue(messageService.getMessage("label.learner")); - cell = row.createCell((short) count++); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(count++); cell.setCellValue(messageService.getMessage("label.monitoring.downloadMarks.username")); Iterator answersIterator = listMonitoredAnswersContainerDTO.iterator(); while(answersIterator.hasNext()) { McMonitoredAnswersDTO mcMonitoredAnswersDTO = (McMonitoredAnswersDTO) answersIterator.next(); - cell = row.createCell((short) count++); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(count++); cell.setCellValue(messageService.getMessage("label.monitoring.downloadMarks.question.mark", new Object[] {count-1, mcMonitoredAnswersDTO.getMark()})); } - cell = row.createCell((short) count++); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(count++); cell.setCellValue(messageService.getMessage("label.total")); Iterator userMarkIterator = usersMarksMap.values().iterator(); @@ -4804,24 +4798,20 @@ McUserMarkDTO userMark = (McUserMarkDTO) userMarkIterator.next(); String currentUserSessionId = userMark.getSessionId(); - cell = row.createCell((short) count++); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(count++); cell.setCellValue(userMark.getFullName()); - cell = row.createCell((short) count++); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(count++); cell.setCellValue(userMark.getUserName()); Integer[] marks = userMark.getMarks(); for(int i=0; i> questionEntry : questionEntries) { // display 1 empty row row = sheet.createRow(idx++); - cell = row.createCell((short) 0); + cell = row.createCell(0); cell.setCellValue(""); questionIdx++; @@ -343,44 +339,39 @@ // display question content row = sheet.createRow(idx++); - cell = row.createCell((short) 0); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(0); cell.setCellValue(resource.getMessage(MonitoringAction.MSG_LABEL_QUESTION) + " " + questionIdx); - cell = row.createCell((short) 1); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(1); cell.setCellValue(removeHTMLTags(question.getDescription())); // display options content Set options = question.getOptions(); row = sheet.createRow(idx++); - cell = row.createCell((short) 0); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(0); cell.setCellValue(resource.getMessage(MonitoringAction.MSG_LABEL_POSSIBLE_ANSWERS)); int optionIdx = 0; for (SurveyOption option : options) { optionIdx++; row = sheet.createRow(idx++); - cell = row.createCell((short) 0); + cell = row.createCell(0); cell.setCellValue(SurveyConstants.OPTION_SHORT_HEADER + optionIdx); - cell = row.createCell((short) 1); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(1); cell.setCellValue(removeHTMLTags(option.getDescription())); } if (question.isAppendText() || question.getType() == SurveyConstants.QUESTION_TYPE_TEXT_ENTRY) { optionIdx++; row = sheet.createRow(idx++); - cell = row.createCell((short) 0); + cell = row.createCell(0); cell.setCellValue(SurveyConstants.OPTION_SHORT_HEADER + optionIdx); - cell = row.createCell((short) 1); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(1); cell.setCellValue(resource.getMessage(MonitoringAction.MSG_LABEL_OPEN_RESPONSE)); } // display 1 empty row row = sheet.createRow(idx++); - cell = row.createCell((short) 0); + cell = row.createCell(0); cell.setCellValue(""); // ////////////////////////// @@ -390,29 +381,28 @@ int cellIdx = 0; row = sheet.createRow(idx++); - cell = row.createCell((short) cellIdx); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(cellIdx); cell.setCellValue(resource.getMessage(MonitoringAction.MSG_LABEL_LEARNER)); // increase one more option number if there are open entry option int optionsNum = options.size(); if (question.isAppendText() || question.getType() == SurveyConstants.QUESTION_TYPE_TEXT_ENTRY) { optionsNum++; } for (cellIdx = 1; cellIdx <= optionsNum; cellIdx++) { - cell = row.createCell((short) cellIdx); + cell = row.createCell(cellIdx); cell.setCellValue(SurveyConstants.OPTION_SHORT_HEADER + cellIdx); } // display all users' answers for this question in multiple rows for (AnswerDTO answer : answers) { row = sheet.createRow(idx++); cellIdx = 0; - cell = row.createCell((short) cellIdx); + cell = row.createCell(cellIdx); cell.setCellValue(answer.getReplier().getLoginName()); // for answer's options for (SurveyOption option : options) { cellIdx++; - cell = row.createCell((short) cellIdx); + cell = row.createCell(cellIdx); if (answer.getAnswer() == null) { break; } @@ -425,8 +415,7 @@ } // for textEntry option if (question.isAppendText() || question.getType() == SurveyConstants.QUESTION_TYPE_TEXT_ENTRY) { - cell = row.createCell((short) ++cellIdx); - cell.setEncoding(HSSFCell.ENCODING_UTF_16); + cell = row.createCell(++cellIdx); if (answer.getAnswer() != null) { cell.setCellValue(removeHTMLTags(answer.getAnswer().getAnswerText())); }