use of org.olat.core.util.openxml.OpenXMLWorksheet in project openolat by klemens.
the class LecturesStatisticsExport method generate.
@Override
protected void generate(OutputStream out) {
try (OpenXMLWorkbook workbook = new OpenXMLWorkbook(out, 2)) {
OpenXMLWorksheet exportSheet = workbook.nextWorksheet();
exportSheet.setHeaderRows(1);
addHeadersAggregated(exportSheet);
addContentAggregated(exportSheet, workbook);
exportSheet = workbook.nextWorksheet();
exportSheet.setHeaderRows(1);
addHeadersDetailled(exportSheet);
addContentDetailled(exportSheet, workbook);
} catch (IOException e) {
log.error("", e);
}
}
use of org.olat.core.util.openxml.OpenXMLWorksheet in project openolat by klemens.
the class XlsMembersExport method export.
public MediaResource export(List<Identity> rows, Map<Identity, StringBuilder> members, Translator translator, List<UserPropertyHandler> userPropertyHandlers) {
String label = "TableExport_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())) + ".xlsx";
return new OpenXMLWorkbookResource(label) {
@Override
protected void generate(OutputStream out) {
try (OpenXMLWorkbook workbook = new OpenXMLWorkbook(out, 1)) {
OpenXMLWorksheet sheet = workbook.nextWorksheet();
createHeader(userPropertyHandlers, translator, sheet, workbook);
createData(members, rows, userPropertyHandlers, sheet);
} catch (IOException e) {
log.error("Unable to export xlsx", e);
}
}
};
}
use of org.olat.core.util.openxml.OpenXMLWorksheet in project OpenOLAT by OpenOLAT.
the class QTI21ArchiveFormat method exportCourseElement.
public MediaResource exportCourseElement() {
FileResourceManager frm = FileResourceManager.getInstance();
File unzippedDirRoot = frm.unzipFileResource(searchParams.getTestEntry().getOlatResource());
resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
ICourse course = CourseFactory.loadCourse(searchParams.getCourseEntry());
courseNode = course.getRunStructure().getNode(searchParams.getNodeIdent());
String label = courseNode.getType() + "_" + StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())) + ".xlsx";
if ("iqself".equals(courseNode.getType())) {
anonymizerCallback = course.getCourseEnvironment().getCoursePropertyManager();
}
// content
final List<AssessmentTestSession> sessions = testSessionDao.getTestSessionsOfResponse(searchParams);
final List<AssessmentResponse> responses = responseDao.getResponse(searchParams);
return new OpenXMLWorkbookResource(label) {
@Override
protected void generate(OutputStream out) {
try (OpenXMLWorkbook workbook = new OpenXMLWorkbook(out, 1)) {
// headers
OpenXMLWorksheet exportSheet = workbook.nextWorksheet();
exportSheet.setHeaderRows(2);
writeHeaders_1(exportSheet, workbook);
writeHeaders_2(exportSheet, workbook);
writeData(sessions, responses, exportSheet, workbook);
} catch (Exception e) {
log.error("", e);
}
}
};
}
use of org.olat.core.util.openxml.OpenXMLWorksheet in project OpenOLAT by OpenOLAT.
the class QTI21ArchiveFormat method exportWorkbook.
public void exportWorkbook(OutputStream exportStream) {
RepositoryEntry testEntry = searchParams.getTestEntry();
FileResourceManager frm = FileResourceManager.getInstance();
File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
// content
final List<AssessmentTestSession> sessions = testSessionDao.getTestSessionsOfResponse(searchParams);
final List<AssessmentResponse> responses = responseDao.getResponse(searchParams);
try (OpenXMLWorkbook workbook = new OpenXMLWorkbook(exportStream, 1)) {
// headers
OpenXMLWorksheet exportSheet = workbook.nextWorksheet();
exportSheet.setHeaderRows(2);
writeHeaders_1(exportSheet, workbook);
writeHeaders_2(exportSheet, workbook);
writeData(sessions, responses, exportSheet, workbook);
} catch (Exception e) {
log.error("", e);
}
}
use of org.olat.core.util.openxml.OpenXMLWorksheet in project OpenOLAT by OpenOLAT.
the class ChatLogHelper method logMediaResource.
public MediaResource logMediaResource(OLATResourceable ores, Locale locale) {
Translator translator = Util.createPackageTranslator(ChatController.class, locale);
String tableExportTitle = translator.translate("logChat.export.title");
String label = tableExportTitle + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())) + ".xlsx";
return new OpenXMLWorkbookResource(label) {
@Override
protected void generate(OutputStream out) {
try (OpenXMLWorkbook workbook = new OpenXMLWorkbook(out, 1)) {
// headers
OpenXMLWorksheet exportSheet = workbook.nextWorksheet();
Row headerRow = exportSheet.newRow();
headerRow.addCell(0, "User", workbook.getStyles().getHeaderStyle());
headerRow.addCell(1, "Date", workbook.getStyles().getHeaderStyle());
headerRow.addCell(2, "Content", workbook.getStyles().getHeaderStyle());
// content
List<InstantMessage> messages = imDao.getMessages(ores, null, 0, -1);
for (InstantMessage message : messages) {
Row dataRow = exportSheet.newRow();
dataRow.addCell(0, message.getFromNickName(), null);
dataRow.addCell(1, message.getCreationDate(), workbook.getStyles().getDateStyle());
dataRow.addCell(2, message.getBody(), null);
}
} catch (IOException e) {
log.error("", e);
}
}
};
}
Aggregations