com.softartisans.excelwriter
Class ExcelTemplate

java.lang.Object
  extended bycom.softartisans.excelwriter.ExcelTemplate

public class ExcelTemplate
extends java.lang.Object

The ExcelTemplate object represents a template* spreadsheet, that is, a file created in Microsoft Excel that contains data markers. A data marker specifies a database column, variable, or array to insert in the spreadsheet column containing the marker.

In the ExcelWriter documentation, the term "template" refers to an ExcelWriter template, not a Microsoft Excel template (.xlt). However, ExcelWriter can open and generate both .xls and .xlt files. Use an .xlt file the same way you would an .xls file. To create an instance of the ExcelTemplate object:

  1. import com.softartisans.excelwriter.ExcelTemplate;
  2. ExcelTemplate xlw = new ExcelTemplate();

Note: The ExcelTemplate object supports Excel's BIFF8 (Excel 97/2000/XP) format only; ExcelTemplate does not support BIFF7 (Excel 95) format templates, and will not generate BIFF7 format files.

(The ExcelApplication object can produce either Excel 97/2000/XP (BIFF8) format files or Excel 95 (BIFF7) format files.)


Field Summary
static int ALL_ROWS
          The maximum number of rows that can be inserted into a spreadsheet.
 
Constructor Summary
ExcelTemplate()
          Creates a new ExcelTemplate object.
 
Method Summary
 java.lang.String getContentType()
          Returns the current setting for the ContentType header sent to a web browser.
 java.lang.String getDecryptPassword()
          Returns the current value of the DecryptPassword.
 java.lang.String getEncryptPassword()
          Returns the current value of the EncryptPassword.
 boolean getExcludeMacros()
          Return the current setting of ExcludeMacros.
 java.lang.String getLicenseKey()
          Returns the license key used for this instance of ExcelWriter.
 boolean getPreserveStrings()
          Returns the current setting of PreserveStrings.
 boolean getRemoveExtraDataMarkers()
          Returns the current value of the RemoveExtraDataMarkers flag.
 int getSpreadsheetsCreatedToday()
          Returns the number of spreadsheets created in the last 24 hours.
static java.lang.String getVersion()
          Returns the exact version of the ExcelWriter product.
 void open(java.io.InputStream stream)
          Opens an ExcelWriter template spreadsheet from an InputStream.
 void open(java.lang.String fileName)
          Opens an ExcelWriter template spreadsheet, that is, a file created in Microsoft Excel that contains data markers where values will be inserted.
 void process()
          Enters datasource values into a new spreadsheet, based on the data marker values in the template.
 void save(javax.servlet.http.HttpServletResponse response)
          Returns output spreadsheet to the browser.
 void save(javax.servlet.http.HttpServletResponse response, java.lang.String fileNameToSend, boolean bOpenInBrowser)
          Returns output spreadsheet to the browser.
 void save(java.io.OutputStream stream)
          Returns the processed spreadsheet to a specified output stream.
 void save(java.lang.String fileName)
          Writes the processed spreadsheet to a specified output file, by path name.
 void setCellDataSource(java.lang.Object cellData, java.lang.String dataMarkerName)
          Set an Object as a data source to bind to a single cell in the template.
 void setColumnDataSource(java.lang.Object[] columnData, java.lang.String dataMarkerName)
          Set an array of Objects as a data source to bind to a single column in the template.
 void setColumnDataSource(java.lang.Object[] columnData, java.lang.String dataMarkerName, int maxRows)
          Set an array of Objects as a data source to bind to a single column in the template.
 void setContentType(java.lang.String contentType)
          Sets the value of the ContentType header sent to a web browser through the save(HttpServletResponse) method.
 void setDataSource(java.lang.Object[][] arrayData, java.lang.String[] columnNames, java.lang.String dataMarkerName)
          Set a two-dimensional array of Objects as a data source to bind to datamarkers in the template.
 void setDataSource(java.lang.Object[][] arrayData, java.lang.String[] columnNames, java.lang.String dataMarkerName, int maxRows, boolean transposeToRowCol)
          Set a two-dimensional array of Objects as a data source to bind to datamarkers in the template.
 void setDataSource(java.sql.ResultSet source, java.lang.String dataMarkerName)
          Set a ResultSet as a data source to bind to template data markers.
 void setDataSource(java.sql.ResultSet source, java.lang.String dataMarkerName, int maxRows)
          Set a ResultSet as a data source to bind to template data markers.
 void setDecryptPassword(java.lang.String password)
          Sets the DecryptPassword.
 void setEncryptPassword(java.lang.String password)
          Sets the EncryptPassword.
 void setExcludeMacros(boolean bExcludeMacros)
          Sets whether ExcelWriter should remove macros from the resulting template or leave them in.
 void setLicenseKey(java.lang.String licenseKey)
          Instructs ExcelTemplate to use a particular license key for the duration of this instance, rather than obtaining one programatically from the License.jar file in the classpath.
 void setPreserveStrings(boolean bPreserveStrings)
          Determines whether data inserted into a template is kept as a string or if an attempt to convert to an Excel data type is made.
 void setRemoveExtraDataMarkers(boolean bRemoveDataMarkers)
          Sets whether ExcelWriter should ignore and remove data markers in the template which don't bind to data sources.
 void setRowDataSource(java.lang.Object[] rowData, java.lang.String[] columnNames, java.lang.String dataMarkerName)
          Set an array of Objects as a data source to bind to a row in the template.
 java.lang.String toString()
          Returns a string representation of the ExcelTemplate object, which gives a summary of the values currently used in the object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL_ROWS

public static final int ALL_ROWS
The maximum number of rows that can be inserted into a spreadsheet. This is the default value for any setDataSource method. The default is 65536 rows.

See Also:
Constant Field Values
Constructor Detail

ExcelTemplate

public ExcelTemplate()
Creates a new ExcelTemplate object.

Method Detail

toString

public java.lang.String toString()
Returns a string representation of the ExcelTemplate object, which gives a summary of the values currently used in the object.

See Also:
Object.toString()

getLicenseKey

public java.lang.String getLicenseKey()
                               throws java.lang.Exception
Returns the license key used for this instance of ExcelWriter. The license key must be contained in a license jar file on the classpath of the application. For assistance with licensing issues, please contact SoftArtisans Technical Support.

Returns:
the license key string found by ExcelWriter.
Throws:
java.lang.Exception - if a valid license key cannot be found in the classpath.

setLicenseKey

public void setLicenseKey(java.lang.String licenseKey)
                   throws java.lang.Exception
Instructs ExcelTemplate to use a particular license key for the duration of this instance, rather than obtaining one programatically from the License.jar file in the classpath. This method is included to assist in debugging license-related issues. For general use, you should use the License.jar created at installation time or from the License Key Utility.

For assistance with licensing issues, please contact SoftArtisans Technical Support.

Parameters:
licenseKey - the license key to use for the duration of this instance.
Throws:
java.lang.Exception - if the license key is invalid for any reason.

getSpreadsheetsCreatedToday

public int getSpreadsheetsCreatedToday()
Returns the number of spreadsheets created in the last 24 hours. In the LE and Free editions, there is a limit of 200 spreadsheets per 24 hour period.

Returns:
the number of spreadsheets created in the last 24 hours.

getVersion

public static java.lang.String getVersion()
Returns the exact version of the ExcelWriter product. The version string has the following format:

  SoftArtisans.ProductName Edition Major.Minor.Patch.Build
  (mmddyyyy-hhmmss-buildMachineId)
 
where:

Returns:
version String, as described above.

setPreserveStrings

public void setPreserveStrings(boolean bPreserveStrings)
Determines whether data inserted into a template is kept as a string or if an attempt to convert to an Excel data type is made. By default, ExcelWriter attempts to use the data type defined by the DataSource, and defaults to strings if the conversion fails.

Parameters:
bPreserveStrings - If true, ExcelWriter will insert all data into the template as strings. If false, ExcelWriter attempts to convert the data to Excel types (numbers, dates, etc).

getPreserveStrings

public boolean getPreserveStrings()
Returns the current setting of PreserveStrings.

Returns:
the current value of PreserveStrings.

setRemoveExtraDataMarkers

public void setRemoveExtraDataMarkers(boolean bRemoveDataMarkers)
Sets whether ExcelWriter should ignore and remove data markers in the template which don't bind to data sources. If a data marker does not match a data source, by default ExcelWriter will throw an exception. In some cases it can be useful to have ExcelWriter remove such data markers and continue working. This value is set to false by default; set it to true to remove extraneous data markers silently.

Parameters:
bRemoveDataMarkers - if set to true, ExcelWriter skips extra data markers, does not render them.

getRemoveExtraDataMarkers

public boolean getRemoveExtraDataMarkers()
Returns the current value of the RemoveExtraDataMarkers flag.

Returns:
the current value of RemoveExtraDataMarkers.

setExcludeMacros

public void setExcludeMacros(boolean bExcludeMacros)
Sets whether ExcelWriter should remove macros from the resulting template or leave them in. When ExcludeMacro is set to true, buttons associated with macros may produce the error "Data may have been lost." Therefore, when excluding macros, remove all associated buttons from the spreadsheet. ... ExcelWriter, by default, will include macros in the resulting spreadsheet.

Parameters:
bExcludeMacros - if set to true, macros in the template will be excluded from the generated spreadsheet.

getExcludeMacros

public boolean getExcludeMacros()
Return the current setting of ExcludeMacros.

Returns:
the current value of ExcludeMacros.

getContentType

public java.lang.String getContentType()
Returns the current setting for the ContentType header sent to a web browser.

Returns:
the value that will be used for the ContentType header.

setContentType

public void setContentType(java.lang.String contentType)
Sets the value of the ContentType header sent to a web browser through the save(HttpServletResponse) method. By default, this value is "application/vnd.ms-excel", which should work for most modern browsers. This value can be set to another value if needed.

Parameters:
contentType - The value to send for the ContentType header.

setDataSource

public void setDataSource(java.sql.ResultSet source,
                          java.lang.String dataMarkerName)
                   throws java.lang.Exception
Set a ResultSet as a data source to bind to template data markers. A data marker is a string beginning with "%%=" which is placed in a cell of the template spreadsheet. Each data marker specifies a database field, variable, or array column to insert in the spreadsheet column containing the marker. Every data marker in the template spreadsheet must refer to a DataSource which has been assigned in the ExcelWriter script.

You may assign many DataSources to a single spreadsheet.

Note that ResultSets, by default, do not support rewinding. While ExcelWriter can use forward-only ResultSets, if you wish to repeat data in a spreadsheet the ResultSet must support rewinding and JDBC 2.0. When creating the statement that will generate a rewindable ResultSet, be sure to use this syntax: Connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);.

By default, the number of rows inserted is limited only by the Excel file format maximum of 65536 rows.

Parameters:
source - The ResultSet to use as the data source.
dataMarkerName - The data source name specified by the data marker, for example, "Orders" corresponds to the data marker "%%=Orders.OrderID". The string passed must begin with a letter. Passing null or the empty string ("") is allowed for the first setDataSource call only; that DataSource will be the implicit data source and can be referred to as "%%=#1.".
Throws:
java.lang.Exception - on error.

setDataSource

public void setDataSource(java.sql.ResultSet source,
                          java.lang.String dataMarkerName,
                          int maxRows)
                   throws java.lang.Exception
Set a ResultSet as a data source to bind to template data markers. A data marker is a string beginning with "%%=" which is placed in a cell of the template spreadsheet. Each data marker specifies a database field, variable, or array column to insert in the spreadsheet column containing the marker. Every data marker in the template spreadsheet must refer to a DataSource which has been assigned in the ExcelWriter script.

You may assign many DataSources to a single spreadsheet.

The maximum number of rows returned for each occurance of the data marker per template row is set for this data source by the third parameter.

Note that ResultSets, by default, do not support rewinding. While ExcelWriter can use forward-only ResultSets, if you wish to repeat data in a spreadsheet the ResultSet must support rewinding and JDBC 2.0. When creating the statement that will generate a rewindable ResultSet, be sure to use this syntax: Connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);.

Parameters:
source - The ResultSet to use as the data source.
dataMarkerName - The data source name specified by the data marker, for example, "Orders" corresponds to the data marker "%%=Orders.OrderID". The string passed must begin with a letter. Passing null or the empty string ("") is allowed for the first setDataSource call only; that DataSource will be the implicit data source and can be referred to as "%%=#1.".
maxRows - The maximum number of rows to insert for this data source, per template row. To use the maximum rows available, use the constant ExcelTemplate.ALL_ROWS.
Throws:
java.lang.Exception - on error.

setCellDataSource

public void setCellDataSource(java.lang.Object cellData,
                              java.lang.String dataMarkerName)
                       throws java.lang.Exception
Set an Object as a data source to bind to a single cell in the template. If the Object is a wrapper around a primitive type, it is inserted as that type. Otherwise, the toString() method is called on the object to generate the data.

A data marker is a string beginning with "%%=" which is placed in a cell of the template spreadsheet. Because there is only a single cell inserted via this method, there is only one field. Thus the proper data marker syntax to use is "%%=$dataMarkerName". With this method, the datamarkers "%%=$dataMarkerName" and "%%=dataMarkerName.#1" are functionally equivelent.

You may assign many DataSources to a single spreadsheet.

Parameters:
cellData - An object to insert as data into the spreadsheet. If it is a primitive type wrapper, such as Integer, ExcelWriter will attempt to convert it into an Excel type. Otherwise, ExcelWriter will call the toString() method on the object.
dataMarkerName - The data source name specified by the data marker, for example, "Orders" corresponds to the data marker "%%=Orders.OrderID". The string passed must begin with a letter. Passing null or the empty string ("") is allowed for the first setDataSource call only; that DataSource will be the implicit data source and can be referred to as "%%=#1.".
Throws:
java.lang.Exception - on error.

setColumnDataSource

public void setColumnDataSource(java.lang.Object[] columnData,
                                java.lang.String dataMarkerName)
                         throws java.lang.Exception
Set an array of Objects as a data source to bind to a single column in the template. If each Object is a wrapper around a primitive type, it is inserted as that type. Otherwise, the toString() method is called on the object to generate the data.

A data marker is a string beginning with "%%=" which is placed in a cell of the template spreadsheet. Because there is only a single column inserted via this method, there is only one field. Thus the proper data marker syntax to use is "%%=$dataMarkerName". With this method, the datamarkers "%%=$dataMarkerName" and "%%=dataMarkerName.#1" are functionally equivelent.

You may assign many DataSources to a single spreadsheet.

Parameters:
columnData - An array of objects to insert as data into the spreadsheet. If each Object is a primitive type wrapper, such as Integer, ExcelWriter will attempt to convert it into an Excel type. Otherwise, ExcelWriter will call the toString() method on the object.
dataMarkerName - The data source name specified by the data marker, for example, "Orders" corresponds to the data marker "%%=Orders.OrderID". The string passed must begin with a letter. Passing null or the empty string ("") is allowed for the first setDataSource call only; that DataSource will be the implicit data source and can be referred to as "%%=#1.".
Throws:
java.lang.Exception - on error.

setColumnDataSource

public void setColumnDataSource(java.lang.Object[] columnData,
                                java.lang.String dataMarkerName,
                                int maxRows)
                         throws java.lang.Exception
Set an array of Objects as a data source to bind to a single column in the template. If each Object is a wrapper around a primitive type, it is inserted as that type. Otherwise, the toString() method is called on the object to generate the data.

A data marker is a string beginning with "%%=" which is placed in a cell of the template spreadsheet. Because there is only a single column inserted via this method, there is only one field. Thus the proper data marker syntax to use is "%%=$dataMarkerName". With this method, the datamarkers "%%=$dataMarkerName" and "%%=dataMarkerName.#1" are functionally equivelent.

You may assign many DataSources to a single spreadsheet.

Parameters:
columnData - An array of objects to insert as data into the spreadsheet. If each Object is a primitive type wrapper, such as Integer, ExcelWriter will attempt to convert it into an Excel type. Otherwise, ExcelWriter will call the toString() method on the object.
dataMarkerName - The data source name specified by the data marker, for example, "Orders" corresponds to the data marker "%%=Orders.OrderID". The string passed must begin with a letter. Passing null or the empty string ("") is allowed for the first setDataSource call only; that DataSource will be the implicit data source and can be referred to as "%%=#1.".
maxRows - The maximum number of rows to insert for this data source, per template row. To use the maximum rows available, use the constant ExcelTemplate.ALL_ROWS.
Throws:
java.lang.Exception - on error.

setRowDataSource

public void setRowDataSource(java.lang.Object[] rowData,
                             java.lang.String[] columnNames,
                             java.lang.String dataMarkerName)
                      throws java.lang.Exception
Set an array of Objects as a data source to bind to a row in the template. If each Object is a wrapper around a primitive type, it is inserted as that type. Otherwise, the toString() method is called on the object to generate the data.

A data marker is a string beginning with "%%=" which is placed in a cell of the template spreadsheet. Each data marker must be of the form "%%=dataMarkerName.columnNames[x]" where columnNames[x] is the string is position x of the array columnNames. Alternatively, you can omit the columnNames array and refer to the column by ordinal, i.e. "%%=dataMarkerName.#x".

Note that the datamarkers for this datasource do not need to be on the same row.

You may assign many DataSources to a single spreadsheet.

Parameters:
rowData - An array of objects to insert as data into the spreadsheet. If each Object is a primitive type wrapper, such as Integer, ExcelWriter will attempt to convert it into an Excel type. Otherwise, ExcelWriter will call the toString() method on the object.
columnNames - An array of strings which gives a unique identification to each element in rowData. It must be the same length as rowData. If this parameter is null, binding can only be performed by ordinal.
dataMarkerName - The data source name specified by the data marker, for example, "Orders" corresponds to the data marker "%%=Orders.OrderID". The string passed must begin with a letter. Passing null or the empty string ("") is allowed for the first setDataSource call only; that DataSource will be the implicit data source and can be referred to as "%%=#1.".
Throws:
java.lang.Exception - on error.

setDataSource

public void setDataSource(java.lang.Object[][] arrayData,
                          java.lang.String[] columnNames,
                          java.lang.String dataMarkerName)
                   throws java.lang.Exception
Set a two-dimensional array of Objects as a data source to bind to datamarkers in the template. If each Object is a wrapper around a primitive type, it is inserted as that type. Otherwise, the toString() method is called on the object to generate the data.

The data must be in the form [column][row]. Thus, an array of data {{"A","B","C"},{"X","Y",Z"}} would be inserted into the template as:
AX
BY
CZ


A data marker is a string beginning with "%%=" which is placed in a cell of the template spreadsheet. Each data marker must be of the form "%%=dataMarkerName.columnNames[x]" where columnNames[x] is the string is position x of the array columnNames. Alternatively, you can omit the columnNames array and refer to the column by ordinal, i.e. "%%=dataMarkerName.#x".

Note that the datamarkers for this datasource do not need to be on the same row.

You may assign many DataSources to a single spreadsheet.

Parameters:
arrayData - A 2D array of objects to insert as data into the spreadsheet, in the form [Column][Row]. If each Object is a primitive type wrapper, such as Integer, ExcelWriter will attempt to convert it into an Excel type. Otherwise, ExcelWriter will call the toString() method on the object.
columnNames - An array of strings which gives a unique identification to each element in rowData. It must be the same length as rowData. If this parameter is null, binding can only be performed by ordinal.
dataMarkerName - The data source name specified by the data marker, for example, "Orders" corresponds to the data marker "%%=Orders.OrderID". The string passed must begin with a letter. Passing null or the empty string ("") is allowed for the first setDataSource call only; that DataSource will be the implicit data source and can be referred to as "%%=#1.".
Throws:
java.lang.Exception - on error.

setDataSource

public void setDataSource(java.lang.Object[][] arrayData,
                          java.lang.String[] columnNames,
                          java.lang.String dataMarkerName,
                          int maxRows,
                          boolean transposeToRowCol)
                   throws java.lang.Exception
Set a two-dimensional array of Objects as a data source to bind to datamarkers in the template. If each Object is a wrapper around a primitive type, it is inserted as that type. Otherwise, the toString() method is called on the object to generate the data.

The data must be in the form [column][row]. Thus, an array of data {{"A","B","C"},{"X","Y",Z"}} would be inserted into the template as:
AX
BY
CZ
If transpose is set to true, the format will be [row][column]. The same array would be inserted as:
ABC
XYZ


A data marker is a string beginning with "%%=" which is placed in a cell of the template spreadsheet. Each data marker must be of the form "%%=dataMarkerName.columnNames[x]" where columnNames[x] is the string is position x of the array columnNames. Alternatively, you can omit the columnNames array and refer to the column by ordinal, i.e. "%%=dataMarkerName.#x".

Note that the datamarkers for this datasource do not need to be on the same row.

You may assign many DataSources to a single spreadsheet.

Parameters:
arrayData - A 2D array of objects to insert as data into the spreadsheet, in the form [Column][Row]. If each Object is a primitive type wrapper, such as Integer, ExcelWriter will attempt to convert it into an Excel type. Otherwise, ExcelWriter will call the toString() method on the object.
columnNames - An array of strings which gives a unique identification to each element in rowData. It must be the same length as rowData. If this parameter is null, binding can only be performed by ordinal.
dataMarkerName - The data source name specified by the data marker, for example, "Orders" corresponds to the data marker "%%=Orders.OrderID". The string passed must begin with a letter. Passing null or the empty string ("") is allowed for the first setDataSource call only; that DataSource will be the implicit data source and can be referred to as "%%=#1.".
maxRows - The maximum number of rows to insert for this data source, per template row. To use the maximum rows available, use the constant ExcelTemplate.ALL_ROWS.
transposeToRowCol - If true, interprets the array as [row][column] rather than [column][row].
Throws:
java.lang.Exception - on error.

open

public void open(java.lang.String fileName)
          throws java.io.IOException
Opens an ExcelWriter template spreadsheet, that is, a file created in Microsoft Excel that contains data markers where values will be inserted.

Note: The ExcelTemplate object supports Excel's BIFF8 (Excel 97/2000/XP) format only. ExcelTemplate does not support BIFF7 (Excel 95) templates, and will not generate BIFF7 format files.

Note: ... actually, the file is not opened here. This method just checks that the file name looks reasonable, and then remembers the file name. The actual file-open is done in the "process" method, so that the process method can be sure to close the file handles at the end of process(), even if there is an error during processing. For this reason, certain file errors may be detected later, during the "process()" method.

Parameters:
fileName - The file name of the template .xls file to open.
Throws:
java.io.IOException - if there is a problem accessing the file.

open

public void open(java.io.InputStream stream)
          throws java.io.IOException
Opens an ExcelWriter template spreadsheet from an InputStream. This method is designed to be used in a Web Application Archive (WAR file) with the method ServletContext.getResourceAsStream("").

Note: if the stream object does not support the mark/reset methods, you will not be able to call process() multiple times for a single template open() call.

Parameters:
stream - An InputStream of the template .xls file to read.
Throws:
java.io.IOException - if there is a problem opening the accessing the input stream or a problem with the template in the stream.

process

public void process()
             throws java.lang.Exception
Enters datasource values into a new spreadsheet, based on the data marker values in the template.

Throws:
java.lang.Exception - if there is a problem processing the data into the template or writing to the stream.

save

public void save(javax.servlet.http.HttpServletResponse response)
          throws java.io.IOException,
                 java.lang.Exception
Returns output spreadsheet to the browser. This method is designed to be called from a Servlet or JSP page, and to return an Excel sheet to the browser. It should be the only method that uses the response object, as it automatically sets headers, clears the body of the response, and flushes it to the client. This is a convenience method; it has the same effect as calling save(aResponse,"generated.xls",true);

Parameters:
response - the response object of this page. For a servlet or JSP page, this is the variable "response".
Throws:
java.lang.Exception - If a problem arises in the template object, the HttpServletResponse object, or in the processed spreadsheet.
java.io.IOException - If an exception occured while writing to the output stream.

save

public void save(javax.servlet.http.HttpServletResponse response,
                 java.lang.String fileNameToSend,
                 boolean bOpenInBrowser)
          throws java.lang.Exception,
                 java.io.IOException
Returns output spreadsheet to the browser. This method is designed to be called from a Servlet or JSP page, and to return an Excel sheet to the browser. It should be the only method that uses the response object, as it automatically sets headers, clears the body of the response, and flushes it to the client.

Parameters:
response - the response object of this page. For a servlet or JSP page, this is the variable "response".
fileNameToSend - the name of the file to show in the browser. If an invalid name, empty string, or null is specified, the default name of "generated.xls" will be sent.
bOpenInBrowser - If true, the Content-Disposition header is set to open the file in the browser (IE only). If false, the browser is sent as an attachment and the user is prompted to save the file. Browsers which cannot embed Excel (i.e., browsers other than Microsoft Internet Explorer) will always open or save the file outside the browser.
Throws:
java.lang.Exception - If a problem arises in the template object, the HttpServletResponse object, or in the processed spreadsheet.
java.io.IOException - If an exception occured while writing to the output stream.

save

public void save(java.io.OutputStream stream)
          throws java.lang.Exception,
                 java.io.IOException
Returns the processed spreadsheet to a specified output stream.

Parameters:
stream - the output stream to write a copy of the currently processed spreadsheet to.
Throws:
java.lang.Exception - If a problem arises in the template object or in the processed spreadsheet.
java.io.IOException - If an exception occured while writing to the output stream.

save

public void save(java.lang.String fileName)
          throws java.io.IOException,
                 java.lang.Exception
Writes the processed spreadsheet to a specified output file, by path name.

Parameters:
fileName - The name of a file to write the currently processed spreadsheet to. Any current contents of the file will be overwritten.
Throws:
java.lang.Exception - If a problem arises while processing template, data sources, or file.
java.io.IOException

setEncryptPassword

public void setEncryptPassword(java.lang.String password)
                        throws java.lang.Exception
Sets the EncryptPassword. Setting this value signifies that the spreadsheet shuold be encrypted Standard "Office 97/2000 Compatible" encryption is used to encrypt the spreadsheet. This is the default encryption used by Excel 97+.

Parameters:
password - The password used to encrypt the spreadsheet.
Throws:
java.lang.Exception - An Exception will be thrown if the password is longer than 15 characters.

getEncryptPassword

public java.lang.String getEncryptPassword()
Returns the current value of the EncryptPassword.

Returns:
The current password used to encrypt the spreadsheet.

setDecryptPassword

public void setDecryptPassword(java.lang.String password)
                        throws java.lang.Exception
Sets the DecryptPassword. Setting this value signifies that the spreadsheet shuold be decrypted before processing. Standard "Office 97/2000 Compatible" decryption is used to encrypt the spreadsheet. This is the default encryption used by Excel 97+.

Parameters:
password - The password used to decrypt the spreadsheet.
Throws:
java.lang.Exception - An Exception will be thrown if the password is longer than 15 characters.

getDecryptPassword

public java.lang.String getDecryptPassword()
Returns the current value of the DecryptPassword.

Returns:
The current password used to decrypt the spreadsheet.