dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13295
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4214: local vn - Supported in xlsx extension.
------------------------------------------------------------
revno: 4214
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-07-27 14:19:08 +0700
message:
local vn - Supported in xlsx extension.
modified:
local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/DefaultReportLocationManager.java
local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/ExcelContentTypeMap.java
local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exporting/GenerateExcelReportGeneric.java
local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataNormalAction.java
local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java
local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponseImport.java
--
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-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/DefaultReportLocationManager.java'
--- local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/DefaultReportLocationManager.java 2011-05-13 09:38:17 +0000
+++ local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/DefaultReportLocationManager.java 2011-07-27 07:19:08 +0000
@@ -45,7 +45,7 @@
private File REPORT;
private File REPORT_TEMP;
-
+
private File REPORT_TEMPLATE;
// -------------------------------------------------------------------------
@@ -127,7 +127,7 @@
}
REPORT_TEMPLATE = new File( REPORT, pathConfig );
-
+
REPORT_TEMPLATE.mkdirs();
return REPORT_TEMPLATE;
=== modified file 'local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/ExcelContentTypeMap.java'
--- local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/ExcelContentTypeMap.java 2011-05-17 08:52:25 +0000
+++ local/vn/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/ExcelContentTypeMap.java 2011-07-27 07:19:08 +0000
@@ -41,6 +41,10 @@
{
private static final String APPLICATION = "application/";
+ public static final String XLS = "xls";
+
+ public static final String XLSX = "xlsx";
+
private static Map<String, List<String>> contentTypes;
static
@@ -49,25 +53,28 @@
List<String> xlsContentTypes = new ArrayList<String>();
- xlsContentTypes.add( APPLICATION + "xls" );
+ xlsContentTypes.add( APPLICATION + XLS );
xlsContentTypes.add( APPLICATION + "vnd.ms-excel" );
xlsContentTypes.add( APPLICATION + "octet-stream" );
- contentTypes.put( "xls", xlsContentTypes );
+ contentTypes.put( XLS, xlsContentTypes );
+
+ List<String> xlsxContentTypes = new ArrayList<String>();
+
+ xlsxContentTypes.add( APPLICATION + XLSX );
+ xlsxContentTypes.add( APPLICATION + "octet-stream" );
+ xlsxContentTypes.add( APPLICATION + "vnd.openxmlformats-officedocument.spreadsheetml.sheet" );
+
+ contentTypes.put( XLSX, xlsxContentTypes );
/*
* List<String> odsContentTypes = new ArrayList<String>();
*
* odsContentTypes.add( APPLICATION + "octet-stream" );
+ * odsContentTypes.add( APPLICATION +
+ * "vnd.oasis.opendocument.spreadsheet" );
*
* contentTypes.put( "ods", odsContentTypes );
- *
- * List<String> xlsxContentTypes = new ArrayList<String>();
- *
- * xlsxContentTypes.add( APPLICATION + "xlsx" ); xlsxContentTypes.add(
- * APPLICATION + "vnd.openxmlformats-officedocument.spreadsheetml.sheet" );
- *
- * contentTypes.put( "xlsx", xlsxContentTypes );
*/
}
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exporting/GenerateExcelReportGeneric.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exporting/GenerateExcelReportGeneric.java 2011-06-07 05:41:55 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exporting/GenerateExcelReportGeneric.java 2011-07-27 07:19:08 +0000
@@ -46,6 +46,7 @@
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.hisp.dhis.aggregation.AggregationService;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementService;
@@ -301,24 +302,16 @@
public void createWorkbookInstance( ReportExcel exportReport )
throws FileNotFoundException, IOException
{
+ this.inputStreamExcelTemplate = new FileInputStream( reportLocationManager.getReportExcelTemplateDirectory()
+ + File.separator + exportReport.getExcelTemplateFile() );
+
if ( checkingExtensionExcelFile( exportReport.getExcelTemplateFile() ) )
{
- this.inputStreamExcelTemplate = new FileInputStream( reportLocationManager
- .getReportExcelTemplateDirectory()
- + File.separator + exportReport.getExcelTemplateFile() );
-
this.templateWorkbook = new HSSFWorkbook( this.inputStreamExcelTemplate );
}
else
{
- /**
- * DO NOT DELETE THIS SNIPPET CODE
- *
- * this.templateWorkbook = new XSSFWorkbook(
- * reportLocationManager.getExportReportTemplateDirectory() +
- * File.separator + exportReport.getExcelTemplateFile() );
- *
- */
+ this.templateWorkbook = new XSSFWorkbook( this.inputStreamExcelTemplate );
}
}
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataNormalAction.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataNormalAction.java 2011-07-20 07:16:20 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataNormalAction.java 2011-07-27 07:19:08 +0000
@@ -56,7 +56,7 @@
}
catch ( Exception ex )
{
- throw new RuntimeException( "Error while previewing the imported value", ex );
+ throw new RuntimeException( "Error while previewing the imported value at normal", ex );
}
}
}
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java 2011-07-18 05:04:23 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java 2011-07-27 07:19:08 +0000
@@ -27,10 +27,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.hisp.dhis.reportexcel.utils.ExcelUtils.convertAlignmentString;
import static org.hisp.dhis.reportexcel.utils.ExcelUtils.convertVerticalString;
import static org.hisp.dhis.reportexcel.utils.ExcelUtils.readSpecialValueByPOI;
-import static org.hisp.dhis.reportexcel.utils.StringUtils.applyPatternDecimalFormat;
import java.io.FileInputStream;
import java.io.IOException;
@@ -46,6 +46,7 @@
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;
import org.apache.poi.xwpf.usermodel.UnderlinePatterns;
/**
@@ -119,7 +120,15 @@
this.cleanUpForResponse();
this.bWRITE_DTD = bWriteDTD;
this.bWRITE_VERSION = bWriteVersion;
- this.WORKBOOK = new HSSFWorkbook( new FileInputStream( pathFileName ) );
+
+ if ( getExtension( pathFileName ).equals( "xls" ) )
+ {
+ this.WORKBOOK = new HSSFWorkbook( new FileInputStream( pathFileName ) );
+ }
+ else
+ {
+ this.WORKBOOK = new XSSFWorkbook( new FileInputStream( pathFileName ) );
+ }
if ( bFormat )
{
@@ -248,8 +257,7 @@
if ( (cell.getCellStyle() != null) || cell.getCellType() != Cell.CELL_TYPE_BLANK )
{
xml.append( "<col no='" + j + "'><data>" );
- xml.append( "<![CDATA[" + applyPatternDecimalFormat( readSpecialValueByPOI( i + 1, j + 1, s ) )
- + "]]></data>" );
+ xml.append( "<![CDATA[" + readSpecialValueByPOI( i + 1, j + 1, s ) + "]]></data>" );
this.readingDetailsFormattedCell( cell, bDetailed );
=== modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponseImport.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponseImport.java 2011-07-18 05:04:23 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponseImport.java 2011-07-27 07:19:08 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.hisp.dhis.reportexcel.utils.ExcelUtils.convertAlignmentString;
import static org.hisp.dhis.reportexcel.utils.ExcelUtils.readSpecialValueByPOI;
@@ -42,6 +43,7 @@
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.hisp.dhis.reportexcel.importitem.ExcelItem;
import org.hisp.dhis.reportexcel.importitem.ExcelItemGroup;
@@ -102,7 +104,14 @@
FileInputStream inputStream = new FileInputStream( new File( pathFileName ) );
- this.WORKBOOK = new HSSFWorkbook( inputStream );
+ if ( getExtension( pathFileName ).equals( "xls" ) )
+ {
+ this.WORKBOOK = new HSSFWorkbook( inputStream );
+ }
+ else
+ {
+ this.WORKBOOK = new XSSFWorkbook( inputStream );
+ }
this.writeFormattedXML( collectSheets, importItems, bWriteDescription, type );
}