Skip to content

Commit

Permalink
SAK-33420 Assignment grade report: .xlsx (sakaiproject#4856)
Browse files Browse the repository at this point in the history
  • Loading branch information
axxter99 authored and ern committed Oct 6, 2017
1 parent dba1793 commit 7a2c1df
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion assignment/bundles/resources/assignment.properties
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ delete_assig.delass = Delete assignments...

downall = Download All

downspr = Download Spreadsheet [XLS]
downspr = Download Spreadsheet [XLSX]

draft = Drafted

Expand Down
2 changes: 1 addition & 1 deletion assignment/bundles/resources/assignment_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ delet=\u524a\u9664
delete_assig.delanass=\u8ab2\u984c\u3092\u524a\u9664...
delete_assig.delass=\u8ab2\u984c\u3092\u524a\u9664...
downall=\u3059\u3079\u3066\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9
downspr=\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8[XLS]\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9
downspr=\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8[XLSX]\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9
draft=\u30c9\u30e9\u30d5\u30c8\u306b\u3057\u307e\u3057\u305f
dupli=\u8907\u88fd
gen.acesubunt=\u6700\u7d42\u53d7\u7406\u65e5\u6642
Expand Down
2 changes: 1 addition & 1 deletion assignment/bundles/resources/assignment_tr_TR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ delet=Sil
delete_assig.delanass=\u00d6devi Sil...
delete_assig.delass=\u00d6devleri Sil...
downall=T\u00fcm\u00fcn\u00fc \u0130ndir
downspr=[XLS] tablosunu indir
downspr=[XLSX] tablosunu indir
draft=Haz\u0131rlanan
dupli=Kopyala
gen.acesubunt=Son Kabul
Expand Down
5 changes: 5 additions & 0 deletions assignment/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@
<artifactId>poi</artifactId>
<version>${sakai.poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${sakai.poi.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@ public void handleAccess(HttpServletRequest req, HttpServletResponse res, Refere
log.error("Could not stream the zip of submissions for ref = {}", ref.getReference());
}
} else if (REF_TYPE_GRADES.equals(ref.getSubType())) {
res.setContentType("application/vnd.ms-excel");
res.setHeader("Content-Disposition", "attachment; filename = export_grades_file.xls");
res.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
res.setHeader("Content-Disposition", "attachment; filename = export_grades_file.xlsx");

try (OutputStream out = res.getOutputStream()) {
gradeSheetExporter.getGradesSpreadsheet(out, ref.getReference());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
import java.util.TreeMap;

import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
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.ss.util.WorkbookUtil;
import org.sakaiproject.assignment.api.AssignmentEntity;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.sakaiproject.assignment.api.AssignmentService;
import org.sakaiproject.assignment.api.AssignmentServiceConstants;
import org.sakaiproject.assignment.api.model.Assignment;
Expand Down Expand Up @@ -119,12 +119,12 @@ public boolean getGradesSpreadsheet(final OutputStream out, final String ref) th
} else {
int rowNum = 0;

HSSFWorkbook wb = new HSSFWorkbook();
Workbook wb = new SXSSFWorkbook();

HSSFSheet sheet = wb.createSheet(WorkbookUtil.createSafeSheetName(sheetName));
Sheet sheet = wb.createSheet(WorkbookUtil.createSafeSheetName(sheetName));

// Create a row and put some cells in it. Rows are 0 based.
HSSFRow row = sheet.createRow(rowNum++);
Row row = sheet.createRow(rowNum++);

row.createCell(0).setCellValue(rb.getString("download.spreadsheet.title"));

Expand All @@ -144,8 +144,8 @@ public boolean getGradesSpreadsheet(final OutputStream out, final String ref) th
row = sheet.createRow(rowNum++);
row.createCell(0).setCellValue("");

HSSFCellStyle style = wb.createCellStyle();
HSSFCell cell;
CellStyle style = wb.createCellStyle();
Cell cell;

// this is the header row number
int headerRowNumber = rowNum;
Expand Down Expand Up @@ -353,7 +353,7 @@ public boolean getGradesSpreadsheet(final OutputStream out, final String ref) th
// The map is already sorted and so we just iterate over it and output rows.
for (Iterator<Map.Entry<Submitter, List<Object>>> resultsIt = results.entrySet().iterator(); resultsIt.hasNext(); ) {
Map.Entry<Submitter, List<Object>> entry = resultsIt.next();
HSSFRow sheetRow = sheet.createRow(rowNum++);
Row sheetRow = sheet.createRow(rowNum++);
Submitter submitter = entry.getKey();
List<Object> rowValues = entry.getValue();
int column = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- start: chef_assignments_instructory_report_submissions.vm -->
<!-- start: chef_assignments_instructor_report_submissions.vm -->
<div class="portletBody">
#navBarHREF( $allowAddAssignment $withGrade $allowGradeSubmission $allowAddAssignment $allowAllGroups $assignmentscheck $allowUpdateSite $enableViewOption $view "" )

Expand Down

0 comments on commit 7a2c1df

Please sign in to comment.