SPT RWT Application API

com.sptci.rwt.webui
Class ExcelDownloadProvider

java.lang.Object
  extended by com.sptci.rwt.webui.ExcelDownloadProvider
All Implemented Interfaces:
nextapp.echo2.app.filetransfer.DownloadProvider

public class ExcelDownloadProvider
extends Object
implements nextapp.echo2.app.filetransfer.DownloadProvider

Action listener for exporting the results of a SQL statement to Excel. This uses the Apache POI HSSF library for creating Excel workbooks.

© Copyright 2007 Sans Pareil Technologies, Inc.

Version:
$Id: ExcelDownloadProvider.java 4123 2008-05-25 21:49:01Z rakesh $
Author:
Rakesh Vidyadharan 2007-10-09

Field Summary
private  ConnectionManager manager
          The connection manager to use to fetch database connection.
private  String query
          The SQL statement to be executed to fetch the data to be exported.
 
Constructor Summary
ExcelDownloadProvider(String query, ConnectionManager manager)
          Create a new instance of the download provider using the specified values.
 
Method Summary
 String getContentDisposition()
          Return the content-disposition for the excel workbook.
 String getContentType()
          Return the content-type for the excel workbook.
 String getFileName()
          Return the file name for the workbook.
 int getSize()
          Returns the size in bytes of the workbook.
 void writeFile(OutputStream out)
          The DownloadProvider implementation method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

query

private final String query
The SQL statement to be executed to fetch the data to be exported.


manager

private final ConnectionManager manager
The connection manager to use to fetch database connection.

Constructor Detail

ExcelDownloadProvider

public ExcelDownloadProvider(String query,
                             ConnectionManager manager)
Create a new instance of the download provider using the specified values.

Parameters:
query - The query to execute.
manager - The manager to use to fetch connection.
Method Detail

getContentType

public String getContentType()
Return the content-type for the excel workbook.

Specified by:
getContentType in interface nextapp.echo2.app.filetransfer.DownloadProvider
Returns:
The content-type for the workbook.

getContentDisposition

public String getContentDisposition()
Return the content-disposition for the excel workbook.

Specified by:
getContentDisposition in interface nextapp.echo2.app.filetransfer.DownloadProvider
Returns:
The content-disposition. Returns attachment to avoid some issues with full content not being pushed to client in inline mode.

getFileName

public String getFileName()
Return the file name for the workbook.

Specified by:
getFileName in interface nextapp.echo2.app.filetransfer.DownloadProvider
Returns:
Returns QueryResults.xls.

getSize

public int getSize()
Returns the size in bytes of the workbook.

Specified by:
getSize in interface nextapp.echo2.app.filetransfer.DownloadProvider
Returns:
Returns -1 to indicate that the size is unknown.

writeFile

public void writeFile(OutputStream out)
               throws IOException
The DownloadProvider implementation method. Generates the excel workbook and streams to the client.

Specified by:
writeFile in interface nextapp.echo2.app.filetransfer.DownloadProvider
Parameters:
out - The OutputStream to which the contents of the Excel workbook is to be written.
Throws:
IOException - If errors are encountered while writing the contents.

SPT RWT Application API