use of org.olat.core.util.openxml.workbookstyle.CellStyle in project OpenOLAT by OpenOLAT.
the class QTI21ArchiveFormat method writeHeaders_1.
private void writeHeaders_1(OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
CellStyle headerStyle = workbook.getStyles().getHeaderStyle();
// first header
Row header1Row = exportSheet.newRow();
int col = 1;
if (anonymizerCallback != null) {
// anonymized name -> test duration
col += 0;
} else {
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler != null) {
col++;
}
}
// homepage -> test duration
col += 1;
}
// course node points and passed
if (courseNode instanceof AssessableCourseNode) {
AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
if (assessableCourseNode.hasScoreConfigured()) {
header1Row.addCell(col++, translator.translate("archive.table.header.node"), headerStyle);
}
if (assessableCourseNode.hasPassedConfigured()) {
if (assessableCourseNode.hasScoreConfigured()) {
col++;
} else {
header1Row.addCell(col++, translator.translate("archive.table.header.node"), headerStyle);
}
}
}
// test points, passed and dates
header1Row.addCell(col++, translator.translate("archive.table.header.test"), headerStyle);
col += 5;
List<AbstractInfos> infos = getItemInfos();
for (int i = 0; i < infos.size(); i++) {
int delta = col;
AbstractInfos info = infos.get(i);
if (info instanceof ItemInfos) {
ItemInfos item = (ItemInfos) info;
if (exportConfig.isResponseCols() || exportConfig.isPointCol() || exportConfig.isTimeCols() || exportConfig.isCommentCol()) {
List<Interaction> interactions = item.getInteractions();
for (int j = 0; j < interactions.size(); j++) {
Interaction interaction = interactions.get(j);
col = interactionArchiveMap.get(interaction.getQtiClassName()).writeHeader1(item.getAssessmentItem(), interaction, i, j, header1Row, col, workbook);
}
}
if (!exportConfig.isResponseCols()) {
col -= col - delta;
}
if (exportConfig.isPointCol()) {
col++;
}
if (exportConfig.isCommentCol()) {
col++;
}
if (exportConfig.isTimeCols()) {
col += anonymizerCallback != null ? 1 : 2;
}
} else if (numOfSections > 1 && info instanceof SectionInfos) {
SectionInfos section = (SectionInfos) info;
if (!section.getItemInfos().isEmpty()) {
String sectionTitle = translator.translate("archive.table.header.section", new String[] { section.getAssessmentSection().getTitle() });
header1Row.addCell(col++, sectionTitle, headerStyle);
}
}
}
}
use of org.olat.core.util.openxml.workbookstyle.CellStyle in project OpenOLAT by OpenOLAT.
the class OpenXMLWorksheet method appendRow.
private void appendRow() {
if (row == null || row.isEmpty())
return;
try {
String rowId = Integer.toString(rowPosition);
writer.writeStartElement("row");
writer.writeAttribute("r", rowId);
int numOfCols = row.size();
for (int j = 0; j < numOfCols; j++) {
Cell cell = row.getCell(j);
if (cell != null && cell.getValue() != null) {
writer.writeStartElement("c");
writer.writeAttribute("r", getColumn(j).concat(rowId));
CellStyle style = cell.getStyle();
if (style != null && style.getIndex() > 0) {
writer.writeAttribute("s", Integer.toString(style.getIndex()));
}
if (cell.getType() == OpenXMLCellType.sharedString) {
writer.writeAttribute("t", "s");
}
writer.writeStartElement("v");
if (cell.getType() == OpenXMLCellType.date) {
cal.setTime((Date) cell.getValue());
double val = internalGetExcelDate(cal, false);
writer.writeCharacters(Double.toString(val));
} else {
writer.writeCharacters(cell.getValue().toString());
}
// end v
writer.writeEndElement();
// end c
writer.writeEndElement();
}
}
// end row
writer.writeEndElement();
} catch (XMLStreamException e) {
log.error("", e);
}
}
use of org.olat.core.util.openxml.workbookstyle.CellStyle in project OpenOLAT by OpenOLAT.
the class CheckListExcelExport method writeHeaders.
private void writeHeaders(OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
CellStyle headerStyle = workbook.getStyles().getHeaderStyle();
// second header
// reset column counter
int col = 0;
Row header2Row = exportSheet.newRow();
String sequentialNumber = translator.translate("column.header.seqnum");
header2Row.addCell(col++, sequentialNumber, headerStyle);
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler == null) {
continue;
}
String header = translator.translate(userPropertyHandler.i18nFormElementLabelKey());
header2Row.addCell(col++, header, headerStyle);
}
// add other user and session information
header2Row.addCell(col++, translator.translate("column.header.homepage"), headerStyle);
// course node points and passed
if (courseNode.hasScoreConfigured()) {
header2Row.addCell(col++, translator.translate("column.header.node.points"), headerStyle);
}
if (courseNode.hasPassedConfigured()) {
header2Row.addCell(col++, translator.translate("column.header.node.passed"), headerStyle);
}
ModuleConfiguration config = courseNode.getModuleConfiguration();
CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
if (list != null && list.getList() != null) {
List<Checkbox> checkboxList = list.getList();
for (Checkbox checkbox : checkboxList) {
String boxTitle = checkbox.getTitle();
header2Row.addCell(col++, boxTitle, headerStyle);
if (courseNode.hasScoreConfigured() && checkbox.getPoints() != null) {
header2Row.addCell(col++, translator.translate("column.header.points"), headerStyle);
}
}
}
}
use of org.olat.core.util.openxml.workbookstyle.CellStyle in project openolat by klemens.
the class CheckListExcelExport method writeHeaders.
private void writeHeaders(OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
CellStyle headerStyle = workbook.getStyles().getHeaderStyle();
// second header
// reset column counter
int col = 0;
Row header2Row = exportSheet.newRow();
String sequentialNumber = translator.translate("column.header.seqnum");
header2Row.addCell(col++, sequentialNumber, headerStyle);
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler == null) {
continue;
}
String header = translator.translate(userPropertyHandler.i18nFormElementLabelKey());
header2Row.addCell(col++, header, headerStyle);
}
// add other user and session information
header2Row.addCell(col++, translator.translate("column.header.homepage"), headerStyle);
// course node points and passed
if (courseNode.hasScoreConfigured()) {
header2Row.addCell(col++, translator.translate("column.header.node.points"), headerStyle);
}
if (courseNode.hasPassedConfigured()) {
header2Row.addCell(col++, translator.translate("column.header.node.passed"), headerStyle);
}
ModuleConfiguration config = courseNode.getModuleConfiguration();
CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
if (list != null && list.getList() != null) {
List<Checkbox> checkboxList = list.getList();
for (Checkbox checkbox : checkboxList) {
String boxTitle = checkbox.getTitle();
header2Row.addCell(col++, boxTitle, headerStyle);
if (courseNode.hasScoreConfigured() && checkbox.getPoints() != null) {
header2Row.addCell(col++, translator.translate("column.header.points"), headerStyle);
}
}
}
}
use of org.olat.core.util.openxml.workbookstyle.CellStyle in project openolat by klemens.
the class OpenXMLWorkbook method appendCellXfs.
/*
<cellXfs count="5">
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" />
<xf numFmtId="0" fontId="0" fillId="2" borderId="0" xfId="0" applyFill="1" />
<xf numFmtId="0" fontId="0" fillId="3" borderId="0" xfId="0" applyFill="1" />
<xf numFmtId="14" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1" />
<xf numFmtId="0" fontId="0" fillId="0" borderId="1" xfId="0" applyBorder="1" />
</cellXfs>
*/
private void appendCellXfs(List<CellStyle> cellXfs, XMLStreamWriter writer) throws XMLStreamException {
writer.writeStartElement("cellXfs");
writer.writeAttribute("count", Integer.toString(cellXfs.size()));
for (CellStyle style : cellXfs) {
appendCellXfs(style, writer);
}
writer.writeEndElement();
}
Aggregations