Index: lams_build/3rdParty.userlibraries
===================================================================
diff -u -rf34ad61132d7a8c888a0839f89fc334c5c8487cc -r5340a74cf11fbd5145b1a7d2d42697587b1bbea4
--- lams_build/3rdParty.userlibraries (.../3rdParty.userlibraries) (revision f34ad61132d7a8c888a0839f89fc334c5c8487cc)
+++ lams_build/3rdParty.userlibraries (.../3rdParty.userlibraries) (revision 5340a74cf11fbd5145b1a7d2d42697587b1bbea4)
@@ -41,7 +41,6 @@
NULL
then no date is printed; if not NULL
- * then text is written out along with current date in the cell; the date is formatted according to
- * {@link #EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT}
- * @param columnNames
- * name of the columns that describe data
parameter
- * @param data
- * array of data to print out; first index of array describes a row, second a column; dates are formatted
- * according to {@link #EXPORT_TO_SPREADSHEET_CELL_DATE_FORMAT}
- * @throws IOException
- * @throws JXLException
- */
- public static void exportToolToExcel(OutputStream out, String sheetName, String title, String dateHeader,
- String[] columnNames, Object[][] data) throws IOException, JXLException {
- WritableWorkbook workbook = Workbook.createWorkbook(out);
- WritableSheet sheet = workbook.createSheet(sheetName, 0);
- // Prepare cell formatter used in all columns
- CellView stretchedCellView = new CellView();
- stretchedCellView.setAutosize(true);
- // Pring title in bold, if needed
- if (!StringUtils.isBlank(title)) {
- Label titleCell = new Label(0, 0, title);
- Font font = titleCell.getCellFormat().getFont();
- WritableFont titleFont = new WritableFont(font);
- titleFont.setBoldStyle(WritableFont.BOLD);
- WritableCellFormat titleCellFormat = new WritableCellFormat(titleFont);
- titleCell.setCellFormat(titleCellFormat);
- sheet.addCell(titleCell);
- }
- // Print current date, if needed
- if (!StringUtils.isBlank(dateHeader)) {
- sheet.addCell(new Label(0, 1, dateHeader));
- SimpleDateFormat titleDateFormat = new SimpleDateFormat(FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT);
- sheet.addCell(new Label(1, 1, titleDateFormat.format(new Date())));
- }
- // Print column names, if needed
- if (columnNames != null) {
- for (int columnIndex = 0; columnIndex < columnNames.length; columnIndex++) {
- sheet.addCell(new Label(columnIndex, 3, columnNames[columnIndex]));
- sheet.setColumnView(columnIndex, stretchedCellView);
- }
- }
- SimpleDateFormat cellDateFormat = new SimpleDateFormat(FileUtil.EXPORT_TO_SPREADSHEET_CELL_DATE_FORMAT);
- Calendar calendar = Calendar.getInstance();
- if (data != null) {
- // Print data
- for (int rowIndex = 0; rowIndex < data.length; rowIndex++) {
- int sheetRowIndex = rowIndex + 4;
- for (int columnIndex = 0; columnIndex < data[rowIndex].length; columnIndex++) {
- Object content = data[rowIndex][columnIndex];
- if (content != null) {
- WritableCell cell = null;
- if (content instanceof Date) {
- Date date = (Date) content;
- cell = new Label(columnIndex, sheetRowIndex, cellDateFormat.format(date));
- } else {
- cell = new Label(columnIndex, sheetRowIndex, content.toString());
- }
- sheet.addCell(cell);
- }
- }
- }
- }
- workbook.write();
- workbook.close();
- }
-
- /**
- * Exports data in CSV format. It uses UTF-8 character set and semicolon as separator.
- *
- * @param out
- * output stream to which the file written; usually taken from HTTP response; it is not closed afterwards
- * @param title
- * title printed in the first (0,0) cell
- * @param dateHeader
- * text describing current date; if NULL
then no date is printed; if not NULL
- * then text is written out along with current date in the cell; the date is formatted according to
- * {@link #EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT}
- * @param columnNames
- * name of the columns that describe data
parameter
- * @param data
- * array of data to print out; first index of array describes a row, second a column; dates are formatted
- * according to {@link #EXPORT_TO_SPREADSHEET_CELL_DATE_FORMAT}
- * @throws IOException
- */
- public static void exportToolToCSV(OutputStream out, String title, String dateHeader, String[] columnNames,
- Object[][] data) throws IOException {
- Writer writer = new OutputStreamWriter(out, FileUtil.ENCODING_UTF_8);
- CSVWriter csv = new CSVWriter(writer, ';');
- String[] line = null;
- // Print title, if needed
- if (!StringUtils.isBlank(title)) {
- line = new String[] { title };
- csv.writeNext(line);
- }
- // Print current date,if needed
- if (!StringUtils.isBlank(dateHeader)) {
- String date = new SimpleDateFormat(FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT).format(new Date());
- line = new String[] { dateHeader, date };
- csv.writeNext(line);
- }
- // Separator
- line = new String[] {};
- csv.writeNext(line);
-
- // Print column names, if needed
- if (columnNames != null) {
- csv.writeNext(columnNames);
- }
- SimpleDateFormat cellDateFormat = new SimpleDateFormat(FileUtil.EXPORT_TO_SPREADSHEET_CELL_DATE_FORMAT);
- // Print data
- if (data != null) {
- for (int rowIndex = 0; rowIndex < data.length; rowIndex++) {
- line = new String[data[rowIndex].length];
- for (int columnIndex = 0; columnIndex < line.length; columnIndex++) {
- Object content = data[rowIndex][columnIndex];
- if (content != null) {
- if (content instanceof Date) {
- Date date = (Date) content;
- line[columnIndex] = cellDateFormat.format(date);
- } else {
- line[columnIndex] = content.toString();
- }
- }
- }
- csv.writeNext(line);
- }
- }
- csv.close();
- }
-
- /**
* Gets the temp dir, creates if not exists, returns java system temp dir if inaccessible
*
* @return
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/DacoConstants.java
===================================================================
diff -u -r096eb3709ec455d412a9ea1d6c503899b5dece17 -r5340a74cf11fbd5145b1a7d2d42697587b1bbea4
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/DacoConstants.java (.../DacoConstants.java) (revision 096eb3709ec455d412a9ea1d6c503899b5dece17)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/DacoConstants.java (.../DacoConstants.java) (revision 5340a74cf11fbd5145b1a7d2d42697587b1bbea4)
@@ -295,8 +295,6 @@
public static final String EXPORT_TO_SPREADSHEET_FILE_NAME = "Data_Collection_Export";
- public static final String PARAM_FORMAT = "format";
-
public static final String KEY_LABEL_EXPORT_FILE_SHEET = "label.export.file.sheet";
public static final String KEY_LABEL_LEARNING_LONGLAT_LATITUDE_UNIT = "label.learning.longlat.latitude.unit";
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/util/DacoExcelUtil.java
===================================================================
diff -u
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/util/DacoExcelUtil.java (revision 0)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/util/DacoExcelUtil.java (revision 5340a74cf11fbd5145b1a7d2d42697587b1bbea4)
@@ -0,0 +1,121 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+/* $Id$ */
+package org.lamsfoundation.lams.tool.daco.util;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import jxl.CellView;
+import jxl.JXLException;
+import jxl.Workbook;
+import jxl.format.Font;
+import jxl.write.Label;
+import jxl.write.WritableCell;
+import jxl.write.WritableCellFormat;
+import jxl.write.WritableFont;
+import jxl.write.WritableSheet;
+import jxl.write.WritableWorkbook;
+
+import org.apache.commons.lang.StringUtils;
+import org.lamsfoundation.lams.util.FileUtil;
+
+public class DacoExcelUtil {
+
+ /**
+ * Exports data in MS Excel (.xls) format.
+ *
+ * @param out
+ * output stream to which the file written; usually taken from HTTP response; it is not closed afterwards
+ * @param sheetName
+ * name of first sheet in Excel workbook; data will be stored in this sheet
+ * @param title
+ * title printed in the first (0,0) cell
+ * @param dateHeader
+ * text describing current date; if NULL
then no date is printed; if not NULL
+ * then text is written out along with current date in the cell; the date is formatted according to
+ * {@link #EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT}
+ * @param columnNames
+ * name of the columns that describe data
parameter
+ * @param data
+ * array of data to print out; first index of array describes a row, second a column; dates are formatted
+ * according to {@link #EXPORT_TO_SPREADSHEET_CELL_DATE_FORMAT}
+ * @throws IOException
+ * @throws JXLException
+ */
+ public static void exportToolToExcel(OutputStream out, String sheetName, String title, String dateHeader,
+ String[] columnNames, Object[][] data) throws IOException, JXLException {
+ WritableWorkbook workbook = Workbook.createWorkbook(out);
+ WritableSheet sheet = workbook.createSheet(sheetName, 0);
+ // Prepare cell formatter used in all columns
+ CellView stretchedCellView = new CellView();
+ stretchedCellView.setAutosize(true);
+ // Pring title in bold, if needed
+ if (!StringUtils.isBlank(title)) {
+ Label titleCell = new Label(0, 0, title);
+ Font font = titleCell.getCellFormat().getFont();
+ WritableFont titleFont = new WritableFont(font);
+ titleFont.setBoldStyle(WritableFont.BOLD);
+ WritableCellFormat titleCellFormat = new WritableCellFormat(titleFont);
+ titleCell.setCellFormat(titleCellFormat);
+ sheet.addCell(titleCell);
+ }
+ // Print current date, if needed
+ if (!StringUtils.isBlank(dateHeader)) {
+ sheet.addCell(new Label(0, 1, dateHeader));
+ SimpleDateFormat titleDateFormat = new SimpleDateFormat(FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT);
+ sheet.addCell(new Label(1, 1, titleDateFormat.format(new Date())));
+ }
+ // Print column names, if needed
+ if (columnNames != null) {
+ for (int columnIndex = 0; columnIndex < columnNames.length; columnIndex++) {
+ sheet.addCell(new Label(columnIndex, 3, columnNames[columnIndex]));
+ sheet.setColumnView(columnIndex, stretchedCellView);
+ }
+ }
+ SimpleDateFormat cellDateFormat = new SimpleDateFormat(FileUtil.EXPORT_TO_SPREADSHEET_CELL_DATE_FORMAT);
+ if (data != null) {
+ // Print data
+ for (int rowIndex = 0; rowIndex < data.length; rowIndex++) {
+ int sheetRowIndex = rowIndex + 4;
+ for (int columnIndex = 0; columnIndex < data[rowIndex].length; columnIndex++) {
+ Object content = data[rowIndex][columnIndex];
+ if (content != null) {
+ WritableCell cell = null;
+ if (content instanceof Date) {
+ Date date = (Date) content;
+ cell = new Label(columnIndex, sheetRowIndex, cellDateFormat.format(date));
+ } else {
+ cell = new Label(columnIndex, sheetRowIndex, content.toString());
+ }
+ sheet.addCell(cell);
+ }
+ }
+ }
+ }
+ workbook.write();
+ workbook.close();
+ }
+}
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/action/MonitoringAction.java
===================================================================
diff -u -r096eb3709ec455d412a9ea1d6c503899b5dece17 -r5340a74cf11fbd5145b1a7d2d42697587b1bbea4
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/action/MonitoringAction.java (.../MonitoringAction.java) (revision 096eb3709ec455d412a9ea1d6c503899b5dece17)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/action/MonitoringAction.java (.../MonitoringAction.java) (revision 5340a74cf11fbd5145b1a7d2d42697587b1bbea4)
@@ -59,6 +59,7 @@
import org.lamsfoundation.lams.tool.daco.model.DacoQuestion;
import org.lamsfoundation.lams.tool.daco.model.DacoUser;
import org.lamsfoundation.lams.tool.daco.service.IDacoService;
+import org.lamsfoundation.lams.tool.daco.util.DacoExcelUtil;
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
import org.lamsfoundation.lams.util.CentralConstants;
import org.lamsfoundation.lams.util.FileUtil;
@@ -233,7 +234,6 @@
String sessionMapID = request.getParameter(DacoConstants.ATTR_SESSION_MAP_ID);
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
Daco daco = (Daco) sessionMap.get(DacoConstants.ATTR_DACO);
- int format = WebUtil.readIntParam(request, DacoConstants.PARAM_FORMAT);
IDacoService service = getDacoService();
// Prepare headers and column names
@@ -392,26 +392,18 @@
Object[][] data = rows.toArray(new Object[][] {});
// Prepare response headers
- String fileName = DacoConstants.EXPORT_TO_SPREADSHEET_FILE_NAME
- + (format == 1 ? CentralConstants.FILE_EXTENSION_XLS : CentralConstants.FILE_EXTENSION_CSV);
+ String fileName = DacoConstants.EXPORT_TO_SPREADSHEET_FILE_NAME + CentralConstants.FILE_EXTENSION_XLS;
fileName = FileUtil.encodeFilenameForDownload(request, fileName);
response.setContentType(CentralConstants.RESPONSE_CONTENT_TYPE_DOWNLOAD);
response.setHeader(CentralConstants.HEADER_CONTENT_DISPOSITION, CentralConstants.HEADER_CONTENT_ATTACHMENT
+ fileName);
MonitoringAction.log.debug("Exporting to a spreadsheet tool content with UID: " + daco.getUid());
ServletOutputStream out = response.getOutputStream();
- switch (format) {
- case 1:
- // Export to XLS
- String sheetName = service.getLocalisedMessage(DacoConstants.KEY_LABEL_EXPORT_FILE_SHEET, null);
- FileUtil.exportToolToExcel(out, sheetName, title, dateHeader, columnNames, data);
- break;
- case 2:
- // Export to CSV
- FileUtil.exportToolToCSV(out, title, dateHeader, columnNames, data);
- break;
- }
+ // Export to XLS
+ String sheetName = service.getLocalisedMessage(DacoConstants.KEY_LABEL_EXPORT_FILE_SHEET, null);
+ DacoExcelUtil.exportToolToExcel(out, sheetName, title, dateHeader, columnNames, data);
+
// Return the file inside response, but not any JSP page
return null;
}
Fisheye: Tag 5340a74cf11fbd5145b1a7d2d42697587b1bbea4 refers to a dead (removed) revision in file `lams_tool_daco/web/pages/export/exportToSpreadsheet.jsp'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_daco/web/pages/monitoring/summary.jsp
===================================================================
diff -u -r096eb3709ec455d412a9ea1d6c503899b5dece17 -r5340a74cf11fbd5145b1a7d2d42697587b1bbea4
--- lams_tool_daco/web/pages/monitoring/summary.jsp (.../summary.jsp) (revision 096eb3709ec455d412a9ea1d6c503899b5dece17)
+++ lams_tool_daco/web/pages/monitoring/summary.jsp (.../summary.jsp) (revision 5340a74cf11fbd5145b1a7d2d42697587b1bbea4)
@@ -6,6 +6,11 @@