Home  Products  Purchase  Downloads  Demos  Forums  Blogs  Ticket  Wiki  API  Corporate


com.aspose.cells
Class WorkbookDesigner

java.lang.Object
  extended by com.aspose.cells.WorkbookDesigner

public class WorkbookDesigner
extends java.lang.Object

Encapsulates the object that represents a designer spreadsheet.


Constructor Summary
WorkbookDesigner()
           
 
Method Summary
 void clearDataSource()
          Clears all data sources.
 void clearDataSource(java.lang.String variable)
          Clears the data source by the source name.
 java.lang.String[] getSmartMarkers(int sheetIndex)
          Gets a collection of smart markers in a spreadsheet.
 Workbook getWorkbook()
          Gets the internal Workbook object.
 void open(java.io.InputStream stream)
          Opens a preset designer spreadsheet.
 void open(java.lang.String designerSpreadsheet)
          Opens a preset designer spreadsheet.
 void process()
          Processes the smart markers and populates the data source values.
 void process(boolean isPreserved)
          Processes the smart markers and populates the data source values.
 void process(int sheetIndex, boolean isPreserved)
          Processes the smart markers and populates the data source values.
 void save(java.io.OutputStream stream)
          Saves the workbook to the given stream.
 void save(java.io.OutputStream stream, int fileFormatType)
          Saves the workbook to the given stream.
 void save(java.lang.String resultSpreadsheet)
          Creates and saves the result spreadsheet to the disk.
 void save(java.lang.String resultSpreadsheet, int fileFormatType)
          Creates and saves the result spreadsheet to the disk.
 void setDataSource(java.sql.ResultSet rs)
          Sets data source of a ResultSet object.
 void setDataSource(java.lang.String dataSourceName, AsposeDataTable dataTable)
          Sets data source of a AsposeDataTable object and binds it to a data source name.
 void setDataSource(java.lang.String variable, java.lang.Object data)
          Sets data binding to a variable.
 void setDataSource(java.lang.String variable, java.lang.Object[] dataArray)
          Sets data array binding to a variable.
 void setDataSource(java.lang.String dataSourceName, java.sql.ResultSet rs)
          Sets data source of a ResultSet object and binds it to a data source name.
 void setDataSource(java.lang.String dataSourceName, java.sql.ResultSet rs, int cacheLimit)
          Sets data source of a ResultSet object and binds it to a data source name.
 void setDataSource(java.lang.String dataSourceName, java.sql.ResultSet rs, int cacheLimit, int recordLimit)
          Sets data source of a ResultSet object and binds it to a data source name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkbookDesigner

public WorkbookDesigner()
Method Detail

getWorkbook

public Workbook getWorkbook()
Gets the internal Workbook object.

Returns:
the internal Workbook object.

setDataSource

public void setDataSource(java.sql.ResultSet rs)
Sets data source of a ResultSet object.

Parameters:
rs - The ResultSet object.

setDataSource

public void setDataSource(java.lang.String dataSourceName,
                          AsposeDataTable dataTable)
Sets data source of a AsposeDataTable object and binds it to a data source name.

Parameters:
dataSourceName - Data source name.
dataTable - The data table.

setDataSource

public void setDataSource(java.lang.String dataSourceName,
                          java.sql.ResultSet rs)
Sets data source of a ResultSet object and binds it to a data source name. An invocation of this method yields exactly the same result as the expression setDataSource(String, ResultSet, int, int) with parameter "cacheLimit" being -1(no cache) and "recordLimit" being -1(no limit).

Parameters:
dataSourceName - Data source name.
rs - The ResultSet object.
See Also:
setDataSource(String, ResultSet, int, int)

setDataSource

public void setDataSource(java.lang.String dataSourceName,
                          java.sql.ResultSet rs,
                          int cacheLimit)
Sets data source of a ResultSet object and binds it to a data source name. An invocation of this method yields exactly the same result as the expression setDataSource(String, ResultSet, int, int) with parameter "recordLimit" being -1(no limit).

Parameters:
dataSourceName - Data source name.
rs - The ResultSet object.
cacheLimit - the cached record limit for ResultSet with type TYPE_FORWARD_ONLY.
See Also:
setDataSource(String, ResultSet, int, int)

setDataSource

public void setDataSource(java.lang.String dataSourceName,
                          java.sql.ResultSet rs,
                          int cacheLimit,
                          int recordLimit)
Sets data source of a ResultSet object and binds it to a data source name. By this method, user can specify the cached records for ResultSet with type TYPE_FORWARD_ONLY. When ResultSet's type is TYPE_FORWARD_ONLY and without cache, if there are multiple rows in the template excel file contain markers that take this ResultSet as data source, only the markers in the first row can be extended and filled with data. For example:
 In the template excel file the markers are:
            Col1        Col2        Col3
 Row1:      &=ds.col1   &=ds.col2   &=ds.col3
 Row2:      &=ds.col1   &=ds.col4
 
 In the ResultSet the records are:
            col1        col2        col3        col4
 Record1:   val11       val12       val13       val14
 Record2:   val21       val22       val23       val24
 Record3:   val31       val32       val33       val34
 
 Without caching:
     workbookDesigner.setDataSource("ds", rs, -1);
     workbookDesigner.process();
 the result in excel file will be:
            Col1        Col2        Col3
 Row1:      val11       val12       val13
 Row1+1:    val21       val22       val23
 Row1+2:    val31       val32       val33
 Row2:      &=ds.col1   &=ds.col4
 
 With caching:
     workbookDesigner.setDataSource("ds", rs, 0); //cache all records
     workbookDesigner.process();
 the result in excel file will be:
            Col1        Col2        Col3
 Row1:      val11       val12       val13
 Row1+1:    val21       val22       val23
 Row1+2:    val31       val32       val33
 Row2:      val11       val14
 Row2+1:    val21       val24
 Row2+2:    val31       val34
 

Parameters:
dataSourceName - Data source name.
rs - The ResultSet object.
cacheLimit - the cached record limit for ResultSet with type TYPE_FORWARD_ONLY. Value can be:
  • -1: no cache
  • 0: cache all records in ResultSet
  • greater than 0: the record count to cache from ResultSet.
If ResultSet's type is not TYPE_FORWARD_ONLY, this parameter will be ignored.
recordLimit - the imported records limit. Value can be:
  • -1: no limit, all records in ResultSet will be imported.
  • 0: the limit will be determined by template file's type. For Excel97-2003, limit is 65536; For Excel2007, limit is 1048576.
  • greater than 0: the maximum record count to be imported from ResultSet.

setDataSource

public void setDataSource(java.lang.String variable,
                          java.lang.Object data)
Sets data binding to a variable.

Parameters:
variable - Variable name created using smark marker.
data - Source data.

setDataSource

public void setDataSource(java.lang.String variable,
                          java.lang.Object[] dataArray)
Sets data array binding to a variable.

Parameters:
variable - Variable name created using smark marker.
dataArray - Source data array.

clearDataSource

public void clearDataSource()
Clears all data sources.


clearDataSource

public void clearDataSource(java.lang.String variable)
Clears the data source by the source name.

Parameters:
variable - Variable name created using smark marker.

getSmartMarkers

public java.lang.String[] getSmartMarkers(int sheetIndex)
Gets a collection of smart markers in a spreadsheet.

Parameters:
sheetIndex - Worksheet index.
Returns:
a collection of smart markers in a spreadsheet.

process

public void process()
Processes the smart markers and populates the data source values.


process

public void process(boolean isPreserved)
Processes the smart markers and populates the data source values.

Parameters:
isPreserved - if the unrecognized smart marker is preserved.

process

public void process(int sheetIndex,
                    boolean isPreserved)
Processes the smart markers and populates the data source values.

Parameters:
sheetIndex - Worksheet index.
isPreserved - Processes the smart markers and populates the data source values.

open

public void open(java.lang.String designerSpreadsheet)
          throws java.io.IOException
Opens a preset designer spreadsheet.

Parameters:
designerSpreadsheet - The preset designer spreadsheet.
Throws:
java.io.IOException - IOException if an I/O error occurs.

open

public void open(java.io.InputStream stream)
          throws java.io.IOException
Opens a preset designer spreadsheet.

Parameters:
stream - inputstream which contains the preset designer spreadsheet.
Throws:
java.io.IOException - IOException if an I/O error occurs.

save

public void save(java.lang.String resultSpreadsheet)
          throws java.io.IOException
Creates and saves the result spreadsheet to the disk.

Parameters:
resultSpreadsheet - Result spreadsheet
Throws:
java.io.IOException - if an I/O error occurs.

save

public void save(java.lang.String resultSpreadsheet,
                 int fileFormatType)
          throws java.io.IOException
Creates and saves the result spreadsheet to the disk.

Parameters:
resultSpreadsheet - Result spreadsheet
fileFormatType - one of the FileFormatType values whcih specifies the file format.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
FileFormatType

save

public void save(java.io.OutputStream stream)
          throws java.io.IOException
Saves the workbook to the given stream.

Parameters:
stream - the stream to write to.
Throws:
java.io.IOException - if an I/O error occurs.

save

public void save(java.io.OutputStream stream,
                 int fileFormatType)
          throws java.io.IOException
Saves the workbook to the given stream.

Parameters:
stream - the stream to write to.
fileFormatType - one of the FileFormatType values whcih specifies the file format.
Throws:
java.io.IOException - if an I/O error occurs.