use of org.olat.core.gui.media.ExcelMediaResource in project OpenOLAT by OpenOLAT.
the class GroupChoiceForm method downloadResults.
private void downloadResults(UserRequest ureq) {
int cdcnt = manageTableData.getColumnCount();
int rcnt = manageTableData.getRowCount();
StringBuilder sb = new StringBuilder();
boolean isAdministrativeUser = securityModule.isUserAllowedAdminProps(ureq.getUserSession().getRoles());
List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(USER_PROPS_ID, isAdministrativeUser);
// additional informations
sb.append(translate("cl.course.title")).append('\t').append(course.getCourseTitle());
sb.append('\n');
String listTitle = checklist.getTitle() == null ? "" : checklist.getTitle();
sb.append(translate("cl.title")).append('\t').append(listTitle);
sb.append('\n').append('\n');
// header
for (int c = 0; c < (cdcnt - 1); c++) {
// skip last column (action)
ColumnDescriptor cd = manageChecklistTable.getColumnDescriptor(c);
String headerKey = cd.getHeaderKey();
String headerVal = cd.translateHeaderKey() ? translate(headerKey) : headerKey;
sb.append('\t').append(headerVal);
}
sb.append('\n');
// checkpoint description
if (isAdministrativeUser) {
sb.append('\t');
}
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler == null)
continue;
sb.append('\t');
}
for (Checkpoint checkpoint : checklist.getCheckpoints()) {
sb.append('\t').append(checkpoint.getDescription());
}
sb.append('\n');
// data
for (int r = 0; r < rcnt; r++) {
for (int c = 0; c < (cdcnt - 1); c++) {
// skip last column (action)
ColumnDescriptor cd = manageChecklistTable.getColumnDescriptor(c);
StringOutput so = new StringOutput();
cd.renderValue(so, r, null);
String cellValue = so.toString();
cellValue = StringHelper.stripLineBreaks(cellValue);
sb.append('\t').append(cellValue);
}
sb.append('\n');
}
String res = sb.toString();
String charset = UserManager.getInstance().getUserCharset(ureq.getIdentity());
ExcelMediaResource emr = new ExcelMediaResource(res, charset);
ureq.getDispatchResult().setResultingMediaResource(emr);
}
use of org.olat.core.gui.media.ExcelMediaResource in project openolat by klemens.
the class DefaultCsvTableExporter method export.
/**
* @see org.olat.core.gui.components.table.TableExporter#export(org.olat.core.gui.components.table.Table)
*/
@Override
public MediaResource export(Table table) {
Translator translator = table.getTranslator();
int cdcnt = table.getColumnCount();
int rcnt = table.getRowCount();
StringBuilder sb = new StringBuilder();
createHeader(table, translator, cdcnt, sb);
sb.append('\n');
createData(table, cdcnt, rcnt, sb);
String res = sb.toString();
// FIXME:FG:6.2:OLAT-3736 a use a charsetprovider interface which can deliver the selected charset of a user
// String charset = UserManager.getInstance().getUserCharset(ureq.getIdentity());
// As a temporary workaround use the default charset
String charset = WebappHelper.getDefaultCharset();
return new ExcelMediaResource(res, charset);
}
use of org.olat.core.gui.media.ExcelMediaResource in project openolat by klemens.
the class GroupChoiceForm method downloadResults.
private void downloadResults(UserRequest ureq) {
int cdcnt = manageTableData.getColumnCount();
int rcnt = manageTableData.getRowCount();
StringBuilder sb = new StringBuilder();
boolean isAdministrativeUser = securityModule.isUserAllowedAdminProps(ureq.getUserSession().getRoles());
List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(USER_PROPS_ID, isAdministrativeUser);
// additional informations
sb.append(translate("cl.course.title")).append('\t').append(course.getCourseTitle());
sb.append('\n');
String listTitle = checklist.getTitle() == null ? "" : checklist.getTitle();
sb.append(translate("cl.title")).append('\t').append(listTitle);
sb.append('\n').append('\n');
// header
for (int c = 0; c < (cdcnt - 1); c++) {
// skip last column (action)
ColumnDescriptor cd = manageChecklistTable.getColumnDescriptor(c);
String headerKey = cd.getHeaderKey();
String headerVal = cd.translateHeaderKey() ? translate(headerKey) : headerKey;
sb.append('\t').append(headerVal);
}
sb.append('\n');
// checkpoint description
if (isAdministrativeUser) {
sb.append('\t');
}
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler == null)
continue;
sb.append('\t');
}
for (Checkpoint checkpoint : checklist.getCheckpoints()) {
sb.append('\t').append(checkpoint.getDescription());
}
sb.append('\n');
// data
for (int r = 0; r < rcnt; r++) {
for (int c = 0; c < (cdcnt - 1); c++) {
// skip last column (action)
ColumnDescriptor cd = manageChecklistTable.getColumnDescriptor(c);
StringOutput so = new StringOutput();
cd.renderValue(so, r, null);
String cellValue = so.toString();
cellValue = StringHelper.stripLineBreaks(cellValue);
sb.append('\t').append(cellValue);
}
sb.append('\n');
}
String res = sb.toString();
String charset = UserManager.getInstance().getUserCharset(ureq.getIdentity());
ExcelMediaResource emr = new ExcelMediaResource(res, charset);
ureq.getDispatchResult().setResultingMediaResource(emr);
}
use of org.olat.core.gui.media.ExcelMediaResource in project OpenOLAT by OpenOLAT.
the class DefaultCsvTableExporter method export.
/**
* @see org.olat.core.gui.components.table.TableExporter#export(org.olat.core.gui.components.table.Table)
*/
@Override
public MediaResource export(Table table) {
Translator translator = table.getTranslator();
int cdcnt = table.getColumnCount();
int rcnt = table.getRowCount();
StringBuilder sb = new StringBuilder();
createHeader(table, translator, cdcnt, sb);
sb.append('\n');
createData(table, cdcnt, rcnt, sb);
String res = sb.toString();
// FIXME:FG:6.2:OLAT-3736 a use a charsetprovider interface which can deliver the selected charset of a user
// String charset = UserManager.getInstance().getUserCharset(ureq.getIdentity());
// As a temporary workaround use the default charset
String charset = WebappHelper.getDefaultCharset();
return new ExcelMediaResource(res, charset);
}
Aggregations