public class SpreadsheetHelpers extends Object
TestSpreadsheetHelpers
Modifier and Type | Field and Description |
---|---|
private int |
debugLevel
Controls amount of diagnostic messages to be generated.
|
private int |
numCols
Number of columns in the current spreadsheet.
|
private int |
numRows
Running count of the number of rows in the current spreadsheet.
|
Constructor and Description |
---|
SpreadsheetHelpers() |
Modifier and Type | Method and Description |
---|---|
private void |
addText(StringBuffer working,
String text) |
String |
endWorkbook()
Generates the ending string for an Excel Workbook in XML format.
|
private String |
endWorksheet()
Generate the XML text to appear at the end of a spreadsheet
within the workbook.
|
private String |
endWorksheet(int numRows,
int numCols) |
protected String |
generateWorksheetHeader(ResultSet rs,
ResultSetMetaData meta,
String columns)
Generate header line for spreadsheet.
|
int |
getDebugLevel()
Returns value of debugLevel
|
void |
listResultSet(ResultSet rs)
Prints the contents of a result set.
|
String |
newWorksheet(String worksheetName,
BufferedReader in)
Use java.io.Reader object to create an Excel worksheet.
|
String |
newWorksheet(String worksheetName,
File inputFile)
Use the contents of a file to create an Excel worksheet.
|
String |
newWorksheet(String worksheetName,
ResultSet rs)
Use the contents of a ResultSet to create an Excel spreadsheet.
|
String |
newWorksheet(String worksheetName,
ResultSet rs,
String columns)
Use the contents of a ResultSet to create an Excel spreadsheet.
|
String |
newWorksheet(String worksheetName,
ResultSet rs,
String columns,
int breakColumn)
Use the contents of a ResultSet to create an Excel worksheet.
|
String |
newWorksheet(String worksheetName,
String input)
Use the contents of a String object to create an Excel spreadsheet.
|
void |
setDebugLevel(int level)
Set amount of diagnostic messages to be printed.
|
String |
startWorkbook()
Returns the character string that should appear at the start of the
workbook.
|
private String |
startWorksheet(String worksheetName,
int numRows,
int numCols)
Generate the XML text to appear at the start of a spreadsheet within the
workbook.
|
void |
stringToFile(String data,
String fileName)
This method constructs a new file containing the
contents of a String object.
|
private int numRows
private int numCols
private int debugLevel
setDebugLevel(int)
,
getDebugLevel()
public SpreadsheetHelpers()
public void setDebugLevel(int level)
A value of 0 indicates that a normal level diagnostic messages are to be printed. Increased values increase the quantity of diagnostic messages, while negative numbers reduce the amount of messages.
level
- Desired level of diagnostic messages.public int getDebugLevel()
debugLevel
,
setDebugLevel(int)
public void stringToFile(String data, String fileName)
data
- String containing information to be moved to filefileName
- Name of file to be generatedpublic void listResultSet(ResultSet rs) throws SQLException
rs
- ResultSet to be printedSQLException
private void addText(StringBuffer working, String text)
public String startWorkbook()
Some of the literal values in the listing below should probably be replaced with calculated values, particularly the date and time of the creation of the document.
private String startWorksheet(String worksheetName, int numRows, int numCols)
worksheetName
- Name of spreadsheetnumRows
- Number of rows in spreadsheetnumCols
- Number of columns in spreadsheetprivate String endWorksheet()
protected String generateWorksheetHeader(ResultSet rs, ResultSetMetaData meta, String columns) throws SQLException
Overriding this method should allow the contents of the header line to be changed as desired.
This method is normally called from the newWorksheet methods.
rs
- Result Set from SQL querymeta
- ResultSetMetaData from SQL querycolumns
- XML statements specifying formatting
of columnsSQLException
public String newWorksheet(String worksheetName, ResultSet rs) throws SQLException
worksheetName
- Name to be used for Excel spreadsheet.rs
- ResultSet object to be used.SQLException
newWorksheet(String, ResultSet, String)
public String newWorksheet(String worksheetName, ResultSet rs, String columns) throws SQLException
worksheetName
- Name to be used for Excel spreadsheetrs
- ResultSet object to be usedcolumns
- String to be inserted into spreadsheet to define
widths of columnsSQLException
public String newWorksheet(String worksheetName, ResultSet rs, String columns, int breakColumn) throws SQLException
worksheetName
- Name to be used for Excel worksheetrs
- ResultSet object to be usedcolumns
- String to be inserted into spreadsheet to define
widths of columnsbreakColumn
- This is the number of the column that will be
used for bursting the reportSQLException
newWorksheet(String, ResultSet)
,
newWorksheet(String, ResultSet, String)
public String newWorksheet(String worksheetName, File inputFile)
worksheetName
- Name of worksheet to be created.inputFile
- Name of file to be readpublic String newWorksheet(String worksheetName, String input)
worksheetName
- Name of spreadsheet to be created.input
- String object to be readpublic String newWorksheet(String worksheetName, BufferedReader in)
worksheetName
- Name of worksheet to be created.in
- String object to be readpublic String endWorkbook()
private String endWorksheet(int numRows, int numCols)