Search in sources :

Example 16 with OpenXMLWorkbook

use of org.olat.core.util.openxml.OpenXMLWorkbook in project openolat by klemens.

the class LectureBlockExport method generate.

@Override
protected void generate(OutputStream out) {
    try (OpenXMLWorkbook workbook = new OpenXMLWorkbook(out, 1)) {
        OpenXMLWorksheet exportSheet = workbook.nextWorksheet();
        generate(exportSheet);
    } catch (IOException e) {
        log.error("", e);
    }
}
Also used : OpenXMLWorkbook(org.olat.core.util.openxml.OpenXMLWorkbook) IOException(java.io.IOException) OpenXMLWorksheet(org.olat.core.util.openxml.OpenXMLWorksheet)

Example 17 with OpenXMLWorkbook

use of org.olat.core.util.openxml.OpenXMLWorkbook 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);
    }
}
Also used : OpenXMLWorkbook(org.olat.core.util.openxml.OpenXMLWorkbook) IOException(java.io.IOException) OpenXMLWorksheet(org.olat.core.util.openxml.OpenXMLWorksheet)

Example 18 with OpenXMLWorkbook

use of org.olat.core.util.openxml.OpenXMLWorkbook 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);
            }
        }
    };
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) OpenXMLWorkbookResource(org.olat.core.util.openxml.OpenXMLWorkbookResource) ShieldOutputStream(org.olat.core.util.io.ShieldOutputStream) ZipOutputStream(java.util.zip.ZipOutputStream) OutputStream(java.io.OutputStream) ICourse(org.olat.course.ICourse) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse) Date(java.util.Date) IOException(java.io.IOException) FileResourceManager(org.olat.fileresource.FileResourceManager) OpenXMLWorkbook(org.olat.core.util.openxml.OpenXMLWorkbook) OpenXMLWorksheet(org.olat.core.util.openxml.OpenXMLWorksheet) File(java.io.File)

Example 19 with OpenXMLWorkbook

use of org.olat.core.util.openxml.OpenXMLWorkbook 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);
    }
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) FileResourceManager(org.olat.fileresource.FileResourceManager) OpenXMLWorkbook(org.olat.core.util.openxml.OpenXMLWorkbook) RepositoryEntry(org.olat.repository.RepositoryEntry) OpenXMLWorksheet(org.olat.core.util.openxml.OpenXMLWorksheet) File(java.io.File) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse) IOException(java.io.IOException)

Example 20 with OpenXMLWorkbook

use of org.olat.core.util.openxml.OpenXMLWorkbook 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);
            }
        }
    };
}
Also used : Translator(org.olat.core.gui.translator.Translator) OpenXMLWorkbookResource(org.olat.core.util.openxml.OpenXMLWorkbookResource) ObjectOutputStream(java.io.ObjectOutputStream) OutputStream(java.io.OutputStream) InstantMessage(org.olat.instantMessaging.InstantMessage) OpenXMLWorkbook(org.olat.core.util.openxml.OpenXMLWorkbook) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) IOException(java.io.IOException) OpenXMLWorksheet(org.olat.core.util.openxml.OpenXMLWorksheet) Date(java.util.Date)

Aggregations

IOException (java.io.IOException)28 OpenXMLWorkbook (org.olat.core.util.openxml.OpenXMLWorkbook)28 OpenXMLWorksheet (org.olat.core.util.openxml.OpenXMLWorksheet)28 OutputStream (java.io.OutputStream)12 Date (java.util.Date)12 OpenXMLWorkbookResource (org.olat.core.util.openxml.OpenXMLWorkbookResource)12 Translator (org.olat.core.gui.translator.Translator)6 Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)6 File (java.io.File)4 ICourse (org.olat.course.ICourse)4 FileResourceManager (org.olat.fileresource.FileResourceManager)4 AssessmentResponse (org.olat.ims.qti21.AssessmentResponse)4 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)4 ObjectOutputStream (java.io.ObjectOutputStream)2 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ZipOutputStream (java.util.zip.ZipOutputStream)2 MediaResource (org.olat.core.gui.media.MediaResource)2 Identity (org.olat.core.id.Identity)2 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)2