← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6479: SqlView - Supporting into export to pdf, xls, and csv files.

 

------------------------------------------------------------
revno: 6479
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-04-04 17:48:27 +0700
message:
  SqlView - Supporting into export to pdf, xls, and csv files.
removed:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/ShowUpSqlViewTableAction.java
added:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/ExportSqlViewResultAction.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewExpandStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewService.java
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/jdbc/JdbcSqlViewExpandStore.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/SessionUtils.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/ExportResultAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm


--
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 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewExpandStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewExpandStore.java	2012-03-01 08:45:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewExpandStore.java	2012-04-04 10:48:27 +0000
@@ -2,6 +2,8 @@
 
 import java.util.Collection;
 
+import org.hisp.dhis.common.Grid;
+
 /**
  * @author Dang Duy Hieu
  * @version $Id SqlViewExpandStore.java July 06, 2010$
@@ -22,7 +24,7 @@
 
     void dropViewTable( String sqlViewName );
 
-    void setUpDataSqlViewTable( SqlViewTable sqlViewTable, String viewTableName );
+    void setUpDataSqlViewTable( Grid sqlViewGrid, String viewTableName );
 
     String setUpViewTableName( String input );
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewService.java	2012-03-01 08:45:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewService.java	2012-04-04 10:48:27 +0000
@@ -29,6 +29,8 @@
 
 import java.util.Collection;
 
+import org.hisp.dhis.common.Grid;
+
 /**
  * @author Dang Duy Hieu
  * @version $Id SqlViewService.java July 06, 2010$
@@ -81,7 +83,7 @@
 
     void dropAllSqlViewTables();
 
-    SqlViewTable getDataSqlViewTable( String viewTableName );
+    Grid getDataSqlViewGrid( String viewTableName );
 
     String testSqlGrammar( String sql );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java	2012-03-01 08:45:42 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java	2012-04-04 10:48:27 +0000
@@ -28,6 +28,8 @@
  */
 
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
+import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.system.grid.ListGrid;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Collection;
@@ -173,13 +175,13 @@
     }
 
     @Override
-    public SqlViewTable getDataSqlViewTable( String viewTableName )
+    public Grid getDataSqlViewGrid( String viewTableName )
     {
-        SqlViewTable sqlViewTable = new SqlViewTable();
-
-        sqlViewExpandStore.setUpDataSqlViewTable( sqlViewTable, viewTableName );
-
-        return sqlViewTable;
+        Grid sqlViewGrid = new ListGrid();
+
+        sqlViewExpandStore.setUpDataSqlViewTable( sqlViewGrid, viewTableName );
+
+        return sqlViewGrid;
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/jdbc/JdbcSqlViewExpandStore.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/jdbc/JdbcSqlViewExpandStore.java	2012-03-22 06:47:56 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/jdbc/JdbcSqlViewExpandStore.java	2012-04-04 10:48:27 +0000
@@ -39,9 +39,9 @@
 
 import org.amplecode.quick.StatementHolder;
 import org.amplecode.quick.StatementManager;
+import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.sqlview.SqlView;
 import org.hisp.dhis.sqlview.SqlViewExpandStore;
-import org.hisp.dhis.sqlview.SqlViewTable;
 import org.springframework.jdbc.BadSqlGrammarException;
 import org.springframework.jdbc.core.JdbcTemplate;
 
@@ -161,7 +161,7 @@
     }
 
     @Override
-    public void setUpDataSqlViewTable( SqlViewTable sqlViewTable, String viewTableName )
+    public void setUpDataSqlViewTable( Grid grid, String viewTableName )
     {
         final StatementHolder holder = statementManager.getHolder();
 
@@ -175,8 +175,8 @@
             throw new RuntimeException( "Failed to get data from view " + viewTableName, e );
         }
 
-        sqlViewTable.createViewerStructure( rs );
-        sqlViewTable.addRecord( rs );
+        grid.addHeaders( rs );
+        grid.addRow( rs );
 
         holder.close();
     }

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/SessionUtils.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/SessionUtils.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/SessionUtils.java	2012-04-04 10:48:27 +0000
@@ -41,6 +41,8 @@
     public static final String KEY_REPORT_TABLE_GRID = "lastReportTableGrid";
     public static final String KEY_REPORT_TABLE_PARAMS = "lastReportTableParams";
     public static final String KEY_DATASET_REPORT_GRID = "lastDataSetReportGrid";
+    public static final String KEY_DATABROWSERGRID = "dataBrowserGridResults";
+    public static final String KEY_SQLVIEW_GRID = "sqlViewGrid";
     
     public static Object getSessionVar( String name )
     {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/ExportResultAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/ExportResultAction.java	2011-03-12 10:25:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/ExportResultAction.java	2012-04-04 10:48:27 +0000
@@ -1,7 +1,7 @@
 package org.hisp.dhis.dataadmin.action.databrowser;
 
 /*
- * Copyright (c) 2004-${year}, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -39,8 +39,6 @@
 public class ExportResultAction
     implements Action
 {
-    private static final String KEY_DATABROWSERGRID = "dataBrowserGridResults";
-
     // -------------------------------------------------------------------------
     // Input / Output
     // -------------------------------------------------------------------------
@@ -70,7 +68,7 @@
 
     public String execute()
     {
-        Grid _grid = (Grid) SessionUtils.getSessionVar( KEY_DATABROWSERGRID );
+        Grid _grid = (Grid) SessionUtils.getSessionVar( SessionUtils.KEY_DATABROWSERGRID );
 
         if ( _grid != null && type != null )
         {

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/ExportSqlViewResultAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/ExportSqlViewResultAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/ExportSqlViewResultAction.java	2012-04-04 10:48:27 +0000
@@ -0,0 +1,123 @@
+package org.hisp.dhis.dataadmin.action.sqlview;
+
+/*
+ * 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 org.hisp.dhis.common.Grid;
+import org.hisp.dhis.sqlview.SqlViewService;
+import org.hisp.dhis.util.SessionUtils;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * Updates a existing sqlview in database.
+ * 
+ * @author Dang Duy Hieu
+ * @version $Id ExportSqlViewResultAction.java July 12, 2010$
+ */
+public class ExportSqlViewResultAction
+    implements Action
+{
+    private static final String DEFAULT_TYPE = "html";
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private SqlViewService sqlViewService;
+
+    public void setSqlViewService( SqlViewService sqlViewService )
+    {
+        this.sqlViewService = sqlViewService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private String viewTableName;
+
+    public void setViewTableName( String viewTableName )
+    {
+        this.viewTableName = viewTableName;
+    }
+
+    private boolean useLast;
+
+    public void setUseLast( boolean useLast )
+    {
+        this.useLast = useLast;
+    }
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    public String getViewTableName()
+    {
+        return viewTableName;
+    }
+
+    private Grid grid;
+
+    public Grid getGrid()
+    {
+        return grid;
+    }
+
+    private String type;
+
+    public String getType()
+    {
+        return type;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+        if ( useLast )
+        {
+            grid = (Grid) SessionUtils.getSessionVar( SessionUtils.KEY_SQLVIEW_GRID );
+        }
+        else
+        {
+            grid = sqlViewService.getDataSqlViewGrid( viewTableName );
+        }
+
+        SessionUtils.setSessionVar( SessionUtils.KEY_SQLVIEW_GRID, grid );
+
+        return type != null ? type : DEFAULT_TYPE;
+    }
+}

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/ShowUpSqlViewTableAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/ShowUpSqlViewTableAction.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/ShowUpSqlViewTableAction.java	1970-01-01 00:00:00 +0000
@@ -1,92 +0,0 @@
-package org.hisp.dhis.dataadmin.action.sqlview;
-
-/*
- * 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 org.hisp.dhis.sqlview.SqlViewService;
-import org.hisp.dhis.sqlview.SqlViewTable;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * Updates a existing sqlview in database.
- * 
- * @author Dang Duy Hieu
- * @version $Id ShowUpSqlViewTableAction.java July 12, 2010$
- */
-public class ShowUpSqlViewTableAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private SqlViewService sqlViewService;
-
-    public void setSqlViewService( SqlViewService sqlViewService )
-    {
-        this.sqlViewService = sqlViewService;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private String viewTableName;
-
-    public void setViewTableName( String viewTableName )
-    {
-        this.viewTableName = viewTableName;
-    }
-
-    // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    public String getViewTableName()
-    {
-        return viewTableName;
-    }
-
-    private SqlViewTable sqlViewTable;
-
-    public SqlViewTable getSqlViewTable()
-    {
-        return sqlViewTable;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-    {
-        sqlViewTable = sqlViewService.getDataSqlViewTable( viewTableName );
-
-        return SUCCESS;
-    }
-}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml	2012-02-29 09:21:50 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml	2012-04-04 10:48:27 +0000
@@ -236,8 +236,8 @@
     <property name="sqlViewService" ref="org.hisp.dhis.sqlview.SqlViewService" />
   </bean>
 
-  <bean id="org.hisp.dhis.dataadmin.action.sqlview.ShowUpSqlViewTableAction"
-      class="org.hisp.dhis.dataadmin.action.sqlview.ShowUpSqlViewTableAction"
+  <bean id="org.hisp.dhis.dataadmin.action.sqlview.ExportSqlViewResultAction"
+      class="org.hisp.dhis.dataadmin.action.sqlview.ExportSqlViewResultAction"
       scope="prototype">
     <property name="sqlViewService" ref="org.hisp.dhis.sqlview.SqlViewService" />
   </bean>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml	2012-03-23 04:01:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml	2012-04-04 10:48:27 +0000
@@ -331,8 +331,11 @@
       <param name="onExceptionReturn">plainTextError</param>
     </action>
 
-    <action name="showDataSqlViewForm" class="org.hisp.dhis.dataadmin.action.sqlview.ShowUpSqlViewTableAction">
-      <result name="success" type="velocity">/main.vm</result>
+    <action name="exportSqlView" class="org.hisp.dhis.dataadmin.action.sqlview.ExportSqlViewResultAction">
+	  <result name="csv" type="gridCsvResult" />
+      <result name="xls" type="gridXlsResult" />
+      <result name="pdf" type="gridPdfResult" />
+      <result name="html" type="velocity">/main.vm</result>
       <param name="menu">/dhis-web-maintenance-dataadmin/menu.vm</param>
       <param name="page">
         /dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm</param>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js	2012-03-01 08:45:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js	2012-04-04 10:48:27 +0000
@@ -83,7 +83,7 @@
 		{
 			if ( json.response == "success" )
 			{
-				window.location.href = "showDataSqlViewForm.action?viewTableName=" + json.message;
+				window.location.href = "exportSqlView.action?viewTableName=" + json.message;
 			}
 			else if ( json.response == "error" )
 			{
@@ -92,3 +92,10 @@
 		}
 	);
 }
+
+function exportSqlView( type )
+{
+	var url = "exportSqlView.action?type=" + type + "&useLast=true";
+
+    window.location.href = url;
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm	2011-03-28 15:28:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm	2012-04-04 10:48:27 +0000
@@ -1,41 +1,47 @@
 <style type="text/css">
-	th.formatLabel
-	{
-	  text-align: center;
-	}
+.gridTable th, .gridTable td
+{
+  text-align: center;
+  width: 150px;
+  line-height: 170%;
+}
 </style>
 
 <h3>$i18n.getString( "view_data_for" ) "$!viewTableName"</h3>
 
-<table class="listTable">
+<div>
+<input type="button" value="$i18n.getString( 'get_report_as_xls' )" onclick="exportSqlView( 'xls' )" style="width:140px"/>
+<input type="button" value="$i18n.getString( 'get_report_as_csv' )" onclick="exportSqlView( 'csv' )" style="width:140px"/>
+<input type="button" value="$i18n.getString( 'get_report_as_pdf' )" onclick="exportSqlView( 'pdf' )" style="width:140px"/>
+<input type="button" value="$i18n.getString( 'back' )" onclick="javascript:window.location.href='showSqlViewListForm.action'" style="width:140px"/>
+</div>
+<br/>
+
+<table class="listTable gridTable">
 	<thead>
 		<tr>
-		#foreach ( $columnName in $sqlViewTable.getHeaders() )
-			<th title="$columnName" class="formatLabel">$columnName</th>
+		#foreach( $header in $!grid.getVisibleHeaders() )
+			<th #if( $header.meta )style="text-align:left"#end>$!encoder.htmlEncode( $header.name )</th>
 		#end
 		</tr>
 	</thead>
-
+	
 	<tbody>
-		#foreach( $row in $sqlViewTable.getRecords() )
+		#foreach( $row in $grid.getVisibleRows() )
 		<tr>
-			#foreach( $columnValue in $row )
-				<td style="text-align:center">
-					#if ($!columnValue)$columnValue 
-					#else<span style="color:blue;font-weight:bold;">null</span>#end
-				</td>
+			#foreach( $col in $row )
+			#set( $index = ( $velocityCount - 1 ) )
+			#if( $grid.getVisibleHeaders().get( $index ).meta )
+			<td style="text-align:left">$!encoder.htmlEncode( $col )</td>
+			#else
+			<td>
+				#if ($!col)$col
+				#else<span style="color:blue;font-weight:bold;">null</span>#end
+			</td>
+			#end
 			#end
 		</tr>
 		#end
 	</tbody>
-</table>
-
-<br/>
-
-<div>
-	<table>
-		<tr>
-			<input type="button" value="$i18n.getString( 'back' )" onclick="window.location.href='showSqlViewListForm.action'" style="width:10em" />
-		</tr>
-	</table>
-</div>
+
+</table>
\ No newline at end of file