dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19852
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8831: local vn - Improved the Preview GUI
------------------------------------------------------------
revno: 8831
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-11-02 11:42:01 +0700
message:
local vn - Improved the Preview GUI
added:
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponseBIS.java
modified:
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/ExportXMLAction.java
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java
local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js
local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/style/previewStyle.css
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/ExportXMLAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/ExportXMLAction.java 2012-05-03 10:04:29 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/ExportXMLAction.java 2012-11-02 04:42:01 +0000
@@ -104,8 +104,7 @@
}
}
- xmlStructureResponse = new XMLStructureResponse( selectionManager.getDownloadFilePath(), sheets, false,
- false, true, false, true ).getXml();
+ xmlStructureResponse = new XMLStructureResponse( selectionManager.getDownloadFilePath(), sheets ).getXml();
return SUCCESS;
}
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java 2012-05-03 10:04:29 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java 2012-11-02 04:42:01 +0000
@@ -29,7 +29,6 @@
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.hisp.dhis.reportsheet.utils.ExcelUtils.convertAlignmentString;
-import static org.hisp.dhis.reportsheet.utils.ExcelUtils.convertVerticalString;
import static org.hisp.dhis.reportsheet.utils.ExcelUtils.readValueByPOI;
import static org.hisp.dhis.reportsheet.utils.NumberUtils.PATTERN_DECIMAL_FORMAT1;
import static org.hisp.dhis.reportsheet.utils.NumberUtils.applyPatternDecimalFormat;
@@ -41,7 +40,6 @@
import java.util.Locale;
import java.util.Set;
-import org.apache.poi.hssf.usermodel.HSSFPatternFormatting;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
@@ -53,7 +51,6 @@
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.apache.poi.xwpf.usermodel.UnderlinePatterns;
/**
* Simple demo class which uses the api to present the contents of an excel 97
@@ -78,16 +75,6 @@
private FormulaEvaluator evaluatorFormula;
- private boolean bWRITE_VERSION;
-
- private boolean bWRITE_DTD;
-
- private static final String XML_VERSION = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
-
- private static final String DOCTYPE_NORMAL = "<!DOCTYPE WORKBOOK SYSTEM \"WORKBOOK.dtd\">";
-
- private static final String DOCTYPE_FORMAT = "<!DOCTYPE WORKBOOK SYSTEM \"formatWORKBOOK.dtd\">";
-
private static final String WORKBOOK_OPENTAG = "<workbook>";
private static final String WORKBOOK_CLOSETAG = "</workbook>";
@@ -121,13 +108,10 @@
* @exception java.io.IOException
*/
- public XMLStructureResponse( String pathFileName, Set<Integer> collectSheets, boolean bWriteDTD,
- boolean bWriteVersion, boolean bFormat, boolean bDetailed, boolean bWriteDescription )
+ public XMLStructureResponse( String pathFileName, Set<Integer> collectSheets )
throws Exception
{
this.cleanUpForResponse();
- this.bWRITE_DTD = bWriteDTD;
- this.bWRITE_VERSION = bWriteVersion;
if ( getExtension( pathFileName ).equals( "xls" ) )
{
@@ -143,61 +127,8 @@
this.evaluatorFormula = WORKBOOK.getCreationHelper().createFormulaEvaluator();
- if ( bFormat )
- {
- writeFormattedXML( collectSheets, bDetailed, bWriteDescription );
- }
- else
- {
- writeXML( collectSheets );
- }
- }
-
- /**
- * Writes out the WORKBOOK data as XML, without formatting information
- */
- private void writeXML( Collection<Integer> collectSheets )
- throws IOException
- {
- if ( this.bWRITE_VERSION )
- {
- xml.append( XML_VERSION );
- }
-
- if ( this.bWRITE_DTD )
- {
- xml.append( DOCTYPE_NORMAL );
- }
-
- xml.append( WORKBOOK_OPENTAG );
-
- for ( Integer sheetNo : collectSheets )
- {
- Sheet sheet = WORKBOOK.getSheetAt( sheetNo - 1 );
-
- xml.append( "<sheet id='" + sheet + "'>" );
- xml.append( "<name><![CDATA[" + sheet.getSheetName() + "]]></name>" );
-
- for ( Row row : sheet )
- {
- xml.append( "<row number='" + row.getRowNum() + "'>" );
-
- for ( Cell cell : row )
- {
- if ( cell.getCellType() != Cell.CELL_TYPE_BLANK )
- {
- xml.append( "<col number='" + cell.getColumnIndex() + "'>" );
- xml.append( "<![CDATA["
- + readValueByPOI( row.getRowNum() + 1, cell.getColumnIndex() + 1, sheet, evaluatorFormula )
- + "]]>" );
- xml.append( "</col>" );
- }
- }
- xml.append( "</row>" );
- }
- xml.append( "</sheet>" );
- }
- xml.append( WORKBOOK_CLOSETAG );
+ writeFormattedXML( collectSheets );
+
}
/**
@@ -208,29 +139,17 @@
* @throws Exception
*/
- private void writeFormattedXML( Collection<Integer> collectSheets, boolean bDetailed, boolean bWriteDescription )
+ private void writeFormattedXML( Collection<Integer> collectSheets )
throws Exception
{
- if ( bWriteDescription )
- {
- this.writeXMLMergedDescription( collectSheets );
- }
-
- if ( this.bWRITE_VERSION )
- {
- xml.append( XML_VERSION );
- }
-
- if ( this.bWRITE_DTD )
- {
- xml.append( DOCTYPE_FORMAT );
- }
+
+ this.writeXMLMergedDescription( collectSheets );
xml.append( WORKBOOK_OPENTAG );
for ( Integer sheet : collectSheets )
{
- writeBySheetNo( sheet, bDetailed );
+ writeBySheetNo( sheet );
}
xml.append( WORKBOOK_CLOSETAG );
@@ -240,7 +159,7 @@
// Sub-methods
// -------------------------------------------------------------------------
- private void writeBySheetNo( int sheetNo, boolean bDetailed )
+ private void writeBySheetNo( int sheetNo )
{
Sheet s = WORKBOOK.getSheetAt( sheetNo - 1 );
@@ -262,7 +181,7 @@
+ readValueByPOI( row.getRowNum() + 1, cell.getColumnIndex() + 1, s, evaluatorFormula )
+ "]]></data>" );
- this.readingDetailsFormattedCell( s, cell, bDetailed );
+ this.readingDetailsFormattedCell( s, cell );
xml.append( "</col>" );
}
@@ -272,44 +191,28 @@
xml.append( "</sheet>" );
}
- private void readingDetailsFormattedCell( Sheet sheet, Cell objCell, boolean bDetailed )
+ private void readingDetailsFormattedCell( Sheet sheet, Cell objCell )
{
// The format information
CellStyle format = objCell.getCellStyle();
if ( format != null )
{
- xml.append( "<format align='" + convertAlignmentString( format.getAlignment() ) + "'" );
- xml.append( " width='" + sheet.getColumnWidth( objCell.getColumnIndex() ) + "'" );
- xml.append( " border='"
+ xml.append( "<format a='" + convertAlignmentString( format.getAlignment() ) + "'" );
+ xml.append( " b='"
+ (format.getBorderBottom() + format.getBorderLeft() + format.getBorderRight() + format.getBorderTop())
+ "'" );
Font font = WORKBOOK.getFontAt( format.getFontIndex() );
- if ( bDetailed && font != null )
+ if ( font != null )
{
- xml.append( " valign='" + convertVerticalString( format.getVerticalAlignment() ) + "'>" );
-
- xml.append( "<font size='" + font.getFontHeightInPoints() + "'" );
- xml.append( " bold='" + font.getBoldweight() + "'" );
- xml.append( " italic='" + font.getItalic() + "'" );
- xml.append( " underline='" + UnderlinePatterns.valueOf( font.getUnderline() ).name() + "'" );
- xml.append( " color='" + font.getColor() + "'" );
- xml.append( " />" );
-
- // The cell background information
- if ( format.getFillBackgroundColor() != IndexedColors.WHITE.getIndex()
- || format.getFillPattern() != HSSFPatternFormatting.NO_FILL )
- {
- xml.append( "<background colour='" + format.getFillBackgroundColor() + "' />" );
- }
-
- // The cell number/date format
- if ( !format.getDataFormatString().equals( "" ) )
- {
- xml.append( "<format_string string='" + format.getDataFormatString() + "' />" );
- }
+ xml.append( "><font s='" + font.getFontHeightInPoints() + "'" );
+ xml.append( " b='" + (font.getBoldweight() == Font.BOLDWEIGHT_BOLD ? "1" : "0") + "'" );
+ xml.append( " i='" + font.getItalic() + "'" );
+ xml.append( " c='" + getSimilarColor( font.getColor() ) + "'" );
+ xml.append( "/>" );
+
xml.append( "</format>" );
}
else
@@ -325,25 +228,19 @@
private void writeXMLMergedDescription( Collection<Integer> collectSheets )
throws IOException
{
- // Get the Range of the Merged Cells //
- if ( this.bWRITE_VERSION )
- {
- xml.append( XML_VERSION );
- }
-
// Open the main Tag //
xml.append( MERGEDCELL_OPENTAG );
for ( Integer sheet : collectSheets )
{
- writeBySheetNo( sheet );
+ writeMergedInfoBySheetNo( sheet );
}
// Close the main Tag //
xml.append( MERGEDCELL_CLOSETAG );
}
- private void writeBySheetNo( int sheetNo )
+ private void writeMergedInfoBySheetNo( int sheetNo )
{
Sheet sheet = WORKBOOK.getSheetAt( sheetNo - 1 );
CellRangeAddress cellRangeAddress = null;
@@ -360,4 +257,24 @@
}
}
}
+
+ private String getSimilarColor( short index )
+ {
+ if ( IndexedColors.BLUE.getIndex() == index )
+ {
+ return "blue";
+ }
+
+ if ( IndexedColors.DARK_BLUE.getIndex() == index )
+ {
+ return "darkblue";
+ }
+
+ if ( IndexedColors.BROWN.getIndex() == index )
+ {
+ return "brown";
+ }
+
+ return "";
+ }
}
\ No newline at end of file
=== added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponseBIS.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponseBIS.java 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponseBIS.java 2012-11-02 04:42:01 +0000
@@ -0,0 +1,376 @@
+package org.hisp.dhis.reportsheet.preview.action;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import static org.apache.commons.io.FilenameUtils.getExtension;
+import static org.hisp.dhis.reportsheet.utils.ExcelUtils.convertAlignmentString;
+import static org.hisp.dhis.reportsheet.utils.ExcelUtils.convertVerticalString;
+import static org.hisp.dhis.reportsheet.utils.ExcelUtils.readValueByPOI;
+import static org.hisp.dhis.reportsheet.utils.NumberUtils.PATTERN_DECIMAL_FORMAT1;
+import static org.hisp.dhis.reportsheet.utils.NumberUtils.applyPatternDecimalFormat;
+import static org.hisp.dhis.reportsheet.utils.NumberUtils.resetDecimalFormatByLocale;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Locale;
+import java.util.Set;
+
+import org.apache.poi.hssf.usermodel.HSSFPatternFormatting;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.FontUnderline;
+import org.apache.poi.ss.usermodel.FormulaEvaluator;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+/**
+ * Simple demo class which uses the api to present the contents of an excel 97
+ * spreadsheet as an XML document, using a workbook and output stream of your
+ * choice
+ *
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+
+public class XMLStructureResponseBIS
+{
+ /**
+ * The encoding to write
+ */
+ private StringBuffer xml = new StringBuffer( 200000 );
+
+ /**
+ * The workbook we are reading from a given file
+ */
+ private Workbook WORKBOOK;
+
+ private FormulaEvaluator evaluatorFormula;
+
+ private boolean bWRITE_VERSION;
+
+ private boolean bWRITE_DTD;
+
+ private static final String XML_VERSION = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+
+ private static final String DOCTYPE_NORMAL = "<!DOCTYPE WORKBOOK SYSTEM \"WORKBOOK.dtd\">";
+
+ private static final String DOCTYPE_FORMAT = "<!DOCTYPE WORKBOOK SYSTEM \"formatWORKBOOK.dtd\">";
+
+ private static final String WORKBOOK_OPENTAG = "<workbook>";
+
+ private static final String WORKBOOK_CLOSETAG = "</workbook>";
+
+ private static final String MERGEDCELL_OPENTAG = "<MergedCells>";
+
+ private static final String MERGEDCELL_CLOSETAG = "</MergedCells>";
+
+ // -------------------------------------------------------------------------
+ // Get & Set methods
+ // -------------------------------------------------------------------------
+
+ protected String getXml()
+ {
+ return xml.toString();
+ }
+
+ private void cleanUpForResponse()
+ {
+ System.gc();
+ }
+
+ /**
+ * Constructor
+ *
+ * @param w The workbook to interrogate
+ * @param enc The encoding used by the output stream. Null or unrecognized
+ * values cause the encoding to default to UTF8
+ * @param f Indicates whether the generated XML document should contain the
+ * cell format information
+ * @exception java.io.IOException
+ */
+
+ public XMLStructureResponseBIS( String pathFileName, Set<Integer> collectSheets, boolean bWriteDTD,
+ boolean bWriteVersion, boolean bFormat, boolean bDetailed, boolean bWriteDescription )
+ throws Exception
+ {
+ this.cleanUpForResponse();
+ this.bWRITE_DTD = bWriteDTD;
+ this.bWRITE_VERSION = bWriteVersion;
+
+ if ( getExtension( pathFileName ).equals( "xls" ) )
+ {
+ this.WORKBOOK = new HSSFWorkbook( new FileInputStream( pathFileName ) );
+ }
+ else
+ {
+ this.WORKBOOK = new XSSFWorkbook( new FileInputStream( pathFileName ) );
+ }
+
+ resetDecimalFormatByLocale( Locale.GERMAN );
+ applyPatternDecimalFormat( PATTERN_DECIMAL_FORMAT1 );
+
+ this.evaluatorFormula = WORKBOOK.getCreationHelper().createFormulaEvaluator();
+
+ if ( bFormat )
+ {
+ writeFormattedXML( collectSheets, bDetailed, bWriteDescription );
+ }
+ else
+ {
+ writeXML( collectSheets );
+ }
+ }
+
+ /**
+ * Writes out the WORKBOOK data as XML, without formatting information
+ */
+ private void writeXML( Collection<Integer> collectSheets )
+ throws IOException
+ {
+ if ( this.bWRITE_VERSION )
+ {
+ xml.append( XML_VERSION );
+ }
+
+ if ( this.bWRITE_DTD )
+ {
+ xml.append( DOCTYPE_NORMAL );
+ }
+
+ xml.append( WORKBOOK_OPENTAG );
+
+ for ( Integer sheetNo : collectSheets )
+ {
+ Sheet sheet = WORKBOOK.getSheetAt( sheetNo - 1 );
+
+ xml.append( "<sheet id='" + sheet + "'>" );
+ xml.append( "<name><![CDATA[" + sheet.getSheetName() + "]]></name>" );
+
+ for ( Row row : sheet )
+ {
+ xml.append( "<row number='" + row.getRowNum() + "'>" );
+
+ for ( Cell cell : row )
+ {
+ if ( cell.getCellType() != Cell.CELL_TYPE_BLANK )
+ {
+ xml.append( "<col number='" + cell.getColumnIndex() + "'>" );
+ xml.append( "<![CDATA["
+ + readValueByPOI( row.getRowNum() + 1, cell.getColumnIndex() + 1, sheet, evaluatorFormula )
+ + "]]>" );
+ xml.append( "</col>" );
+ }
+ }
+ xml.append( "</row>" );
+ }
+ xml.append( "</sheet>" );
+ }
+ xml.append( WORKBOOK_CLOSETAG );
+ }
+
+ /**
+ * Writes out the WORKBOOK data as XML, with formatting information
+ *
+ * @param bDetailed
+ *
+ * @throws Exception
+ */
+
+ private void writeFormattedXML( Collection<Integer> collectSheets, boolean bDetailed, boolean bWriteDescription )
+ throws Exception
+ {
+ if ( bWriteDescription )
+ {
+ this.writeXMLMergedDescription( collectSheets );
+ }
+
+ if ( this.bWRITE_VERSION )
+ {
+ xml.append( XML_VERSION );
+ }
+
+ if ( this.bWRITE_DTD )
+ {
+ xml.append( DOCTYPE_FORMAT );
+ }
+
+ xml.append( WORKBOOK_OPENTAG );
+
+ for ( Integer sheet : collectSheets )
+ {
+ writeBySheetNo( sheet, bDetailed );
+ }
+
+ xml.append( WORKBOOK_CLOSETAG );
+ }
+
+ // -------------------------------------------------------------------------
+ // Sub-methods
+ // -------------------------------------------------------------------------
+
+ private void writeBySheetNo( int sheetNo, boolean bDetailed )
+ {
+ Sheet s = WORKBOOK.getSheetAt( sheetNo - 1 );
+
+ xml.append( "<sheet id='" + (sheetNo) + "'>" );
+ xml.append( "<name><![CDATA[" + s.getSheetName() + "]]></name>" );
+
+ for ( Row row : s )
+ {
+ xml.append( "<row index='" + row.getRowNum() + "'>" );
+
+ for ( Cell cell : row )
+ {
+ // Remember that empty cells can contain format information
+ if ( (cell.getCellStyle() != null || cell.getCellType() != Cell.CELL_TYPE_BLANK)
+ && !s.isColumnHidden( cell.getColumnIndex() ) )
+ {
+ xml.append( "<col no='" + cell.getColumnIndex() + "'>" );
+ xml.append( "<data><![CDATA["
+ + readValueByPOI( row.getRowNum() + 1, cell.getColumnIndex() + 1, s, evaluatorFormula )
+ + "]]></data>" );
+
+ this.readingDetailsFormattedCell( s, cell, bDetailed );
+
+ xml.append( "</col>" );
+ }
+ }
+ xml.append( "</row>" );
+ }
+ xml.append( "</sheet>" );
+ }
+
+ private void readingDetailsFormattedCell( Sheet sheet, Cell objCell, boolean bDetailed )
+ {
+ // The format information
+ CellStyle format = objCell.getCellStyle();
+
+ if ( format != null )
+ {
+ xml.append( "<format a='" + convertAlignmentString( format.getAlignment() ) + "'" );
+ xml.append( " w='" + sheet.getColumnWidth( objCell.getColumnIndex() ) + "'" );
+ xml.append( " b='" + (format.getBorderBottom() + format.getBorderLeft() + format.getBorderRight() + format.getBorderTop()) + "'" );
+
+ Font font = WORKBOOK.getFontAt( format.getFontIndex() );
+
+ if ( bDetailed && font != null )
+ {
+ xml.append( " valign='" + convertVerticalString( format.getVerticalAlignment() ) + "'>" );
+
+ xml.append( "<font s='" + font.getFontHeightInPoints() + "'" );
+ xml.append( " b='" + (font.getBoldweight() == Font.BOLDWEIGHT_BOLD ? "1" : "0") + "'" );
+ xml.append( " i='" + font.getItalic() + "'" );
+ xml.append( " u='" + FontUnderline.valueOf( font.getUnderline() ).name() + "'" );
+ xml.append( " c='" + getSimilarColor( font.getColor() ) + "'" );
+ xml.append( "/>" );
+
+ // The cell background information
+ if ( format.getFillBackgroundColor() != IndexedColors.WHITE.getIndex()
+ || format.getFillPattern() != HSSFPatternFormatting.NO_FILL )
+ {
+ xml.append( "<bg c='" + format.getFillBackgroundColor() + "'/>" );
+ }
+
+ // The cell number/date format
+ if ( !format.getDataFormatString().equals( "" ) )
+ {
+ xml.append( "<dfs s='" + format.getDataFormatString() + "'/>" );
+ }
+ xml.append( "</format>" );
+ }
+ else
+ {
+ xml.append( "/>" );
+ }
+ }
+ }
+
+ // -------------------------------------------------------------------------
+ // Get the merged cell's information
+ // -------------------------------------------------------------------------
+ private void writeXMLMergedDescription( Collection<Integer> collectSheets )
+ throws IOException
+ {
+ // Get the Range of the Merged Cells //
+ if ( this.bWRITE_VERSION )
+ {
+ xml.append( XML_VERSION );
+ }
+
+ // Open the main Tag //
+ xml.append( MERGEDCELL_OPENTAG );
+
+ for ( Integer sheet : collectSheets )
+ {
+ writeBySheetNo( sheet );
+ }
+
+ // Close the main Tag //
+ xml.append( MERGEDCELL_CLOSETAG );
+ }
+
+ private void writeBySheetNo( int sheetNo )
+ {
+ Sheet sheet = WORKBOOK.getSheetAt( sheetNo - 1 );
+ CellRangeAddress cellRangeAddress = null;
+
+ for ( int i = 0; i < sheet.getNumMergedRegions(); i++ )
+ {
+ cellRangeAddress = sheet.getMergedRegion( i );
+
+ if ( cellRangeAddress.getFirstColumn() != cellRangeAddress.getLastColumn() )
+ {
+ xml.append( "<cell " + "iKey='" + (sheetNo) + "#" + cellRangeAddress.getFirstRow() + "#"
+ + cellRangeAddress.getFirstColumn() + "'>"
+ + (cellRangeAddress.getLastColumn() - cellRangeAddress.getFirstColumn() + 1) + "</cell>" );
+ }
+ }
+ }
+
+ private String getSimilarColor( short index )
+ {
+ if ( IndexedColors.DARK_BLUE.getIndex() == index || IndexedColors.BLUE.getIndex() == index )
+ {
+ return "blue";
+ }
+
+ if ( IndexedColors.BROWN.getIndex() == index )
+ {
+ return "brown";
+ }
+
+ return "";
+ }
+}
\ No newline at end of file
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js 2012-11-01 02:12:05 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js 2012-11-02 04:42:01 +0000
@@ -8,7 +8,7 @@
importItemIds = new Array();
htmlStyle = ["<style type='text/css'>"];
-htmlStyle.push( "td.printclass { font-size: 12px; }" );
+htmlStyle.push( "td.printSetup { font-size: 12px; }" );
htmlStyle.push( ".ui-preview-table{ border-collapse: collapse; }" );
htmlStyle.push( ".ui-preview-normal{ font-weight: bold; color: blue }" );
htmlStyle.push( ".ui-widget-content { border: 1px solid #a6c9e2; background: #fcfdfd url(images/ui-bg_inset-hard_100_fcfdfd_1x100.png) 50% bottom repeat-x; color: #222222; }" );
@@ -139,9 +139,12 @@
if ( _index == _number )
{
var _sData = getElementValue( _cols[j], 'data' );
- var _align = getElementAttribute( _cols[j], 'format', 'align' );
- var _border = getElementAttribute( _cols[j], 'format', 'border' );
- //var _width = getElementAttribute( _cols[j], 'format', 'width' );
+ var _align = getElementAttribute( _cols[j], 'format', 'a' );
+ var _border = getElementAttribute( _cols[j], 'format', 'b' );
+ var _size = getElementAttribute( _cols[j], 'font', 's' );
+ var _bold = getElementAttribute( _cols[j], 'font', 'b' );
+ var _italic = getElementAttribute( _cols[j], 'font', 'i' );
+ var _color = getElementAttribute( _cols[j], 'font', 'c' );
// If this cell is merged - Key's form: Sheet#Row#Col
_sPattern = _orderSheet + "#" + i + "#" + _number;
@@ -150,21 +153,31 @@
// Jumping for <For Loop> AND <Empty Cells>
j = Number(j) + Number(_colspan);
_index = Number(_index) + Number(_colspan);
+ _size = Number(_size) + 2;
- //_sHTML.push( "<td align='", _align, "' width='", _width, "px' colspan='", _colspan, "'" );
_sHTML.push( "<td align='", _align, "' colspan='", _colspan, "'" );
- _sHTML.push( " class='printclass" );
+ _sHTML.push( " style='font-size:", _size, "px" );
+ _sHTML.push( _color == "" ? "'" : ";color:" + _color + "'" );
+ _sHTML.push( " class='printSetup" );
_sHTML.push( _border > 0 ? " ui-widget-content" : "" );
- // Preview without importing
- if ( keyId && keyId.length > 0 )
+ if ( keyId && keyId.length > 0 ) // Used for Importing
{
_sHTML.push( " ui-preview-unselected' id='", keyId );
}
- else if ( !isImport && isRealNumber( _sData.replace( /[.,]/g, "" ) ) )
- {
- _sHTML.push( " ui-preview-normal" );
- }
+ else if ( isImport && isRealNumber( _sData.replace( /[.,]/g, "" ) ) )
+ {
+ _sHTML.push( " ui-preview-number" );
+ }
+ else if ( _bold == "1" )
+ {
+ _sData = "<b>" + _sData + "</b>";
+ }
+ if ( _italic == "true" )
+ {
+ _sData = "<i>" + _sData + "</i>";
+ }
+
_sHTML.push( "'>", _sData, "</td>" );
}
}
@@ -174,7 +187,7 @@
}
tabsHTML.push( '</ul>', _sHTML.join(''), '</div>' );
-
+
jQuery( '#previewDiv' ).html( tabsHTML.join('') );
jQuery( '#tabs' ).tabs({ collapsible : true });
enable( 'printExcelReportButton' );
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/style/previewStyle.css'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/style/previewStyle.css 2011-11-09 07:34:53 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/style/previewStyle.css 2012-11-02 04:42:01 +0000
@@ -1,5 +1,5 @@
.ui-preview-table{ border-collapse: collapse; }
-.ui-preview-normal{ font-weight: bold; color: blue }
+.ui-preview-number{ font-weight: bold; color: blue }
.ui-preview-unselected{ font-weight: bold; color: blue; cursor:pointer }
.ui-preview-selected{ background: #F39814; color: white; cursor:pointer }
.ui-preview-mouseover{ background: #FECA40; color: white; cursor:pointer }