public class SpreadsheetHelpers extends Object
TestSpreadsheetHelpers
Constructor and Description |
---|
SpreadsheetHelpers() |
Modifier and Type | Method and Description |
---|---|
String |
endWorkbook()
Generates the ending string for an Excel Workbook in XML format.
|
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.
|
void |
stringToFile(String data,
String fileName)
This method constructs a new file containing the
contents of a String object.
|
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
- if database errorspublic 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.
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
- if database errorspublic String newWorksheet(String worksheetName, ResultSet rs) throws SQLException
worksheetName
- Name to be used for Excel spreadsheet.rs
- ResultSet object to be used.SQLException
- if database errorsnewWorksheet(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
- if database errorspublic 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
- if database errorsnewWorksheet(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()
Copyright © 2017. All rights reserved.