Search in sources :

Example 66 with Row

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

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

Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)66 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)24 Date (java.util.Date)12 Identity (org.olat.core.id.Identity)12 IOException (java.io.IOException)10 Translator (org.olat.core.gui.translator.Translator)10 OpenXMLWorkbook (org.olat.core.util.openxml.OpenXMLWorkbook)10 OpenXMLWorksheet (org.olat.core.util.openxml.OpenXMLWorksheet)10 OutputStream (java.io.OutputStream)8 CellStyle (org.olat.core.util.openxml.workbookstyle.CellStyle)8 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)8 User (org.olat.core.id.User)6 Formatter (org.olat.core.util.Formatter)6 OpenXMLWorkbookResource (org.olat.core.util.openxml.OpenXMLWorkbookResource)6 AssociateInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction)6 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)6 CustomInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.CustomInteraction)6 DrawingInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction)6 EndAttemptInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction)6 ExtendedTextInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction)6