Package de.businesscode.bcdui.wrs.export
Class ExcelSylkTemplate
- java.lang.Object
-
- de.businesscode.bcdui.wrs.export.ExcelSylkTemplate
-
public class ExcelSylkTemplate extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ExcelSylkTemplate.ColumnMapping
This class encapsulates a pair of a column caption and the respective data column name.
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
addInfoFormat
protected java.lang.String[]
colFormats
protected java.lang.String
columnNameFormat
protected java.lang.String
defaultFormat
protected java.lang.String
generalOptions
protected boolean[]
getsQuotes
protected java.lang.String
header
protected java.lang.String
httpHeader
protected java.lang.String
idRecord
protected boolean[]
isTranslated
-
Constructor Summary
Constructors Constructor Description ExcelSylkTemplate(java.sql.ResultSetMetaData metaData, int rowCountIfKnown)
Creates an Excel exported instance and exports all rows that occur in the metaData.ExcelSylkTemplate(java.sql.ResultSetMetaData metaData, int rowCountIfKnown, I18nDbResources i18nDbResources)
ExcelSylkTemplate(java.sql.ResultSetMetaData metaData, int rowCountIfKnown, java.util.List<ExcelSylkTemplate.ColumnMapping> orderedLogicalColumnNames)
Creates an Excel exported instance.ExcelSylkTemplate(java.sql.ResultSetMetaData metaData, int rowCountIfKnown, java.util.List<ExcelSylkTemplate.ColumnMapping> orderedLogicalColumnNames, I18nDbResources i18nDbResources)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
escapeColNamesForSylk(java.util.List<de.businesscode.bcdui.wrs.export.ExcelSylkTemplate.ColumnMappingEx> orderedLogicalColumnNames)
java.lang.String
getAddInfo()
java.lang.String
getApplicationURL()
protected java.lang.String
getColFormatDeclarations()
protected java.lang.String
getContentRecord(java.lang.String content, int colNr, java.lang.String extraData)
static java.lang.String
getDaysSince1900(java.lang.String dateString)
java.lang.String
getHttpHeader()
java.util.HashMap<java.lang.String,java.lang.String>
getHttpHeadersMap()
get hash with wishContents of column with linksprotected java.lang.String
getStandardHeader()
protected void
readColFormats(java.sql.ResultSetMetaData metaData, java.util.List<de.businesscode.bcdui.wrs.export.ExcelSylkTemplate.ColumnMappingEx> orderedLogicalColumnNames)
void
setAddInfo(java.lang.String addInfo)
void
setApplicationURL(java.lang.String applicationURL)
void
setHttpHeader(java.lang.String httpHeader)
void
setHttpHeadersMap(java.util.HashMap<java.lang.String,java.lang.String> headersMap)
set the hash with url string captions for the exel exportprotected void
writeAddInfo(java.io.PrintWriter output)
protected void
writeColNamesRow(java.io.PrintWriter output)
protected void
writeEndRecord(java.io.PrintWriter output)
static void
writeErrorMessage(java.io.PrintWriter output, java.lang.String message)
write the error message into the actual excel file contenttype from servlet must be "application/vnd.ms-excel"protected void
writeHeader(java.io.PrintWriter output)
protected int
writeRowsWoFormat(java.io.PrintWriter output, java.sql.ResultSet resultSet, int startRow, int nrRowsToFlush)
int
writeStandardTable(java.io.PrintWriter output, java.sql.ResultSet resultSet, int nrRowsToFlush)
write a the table with the 'standard' (see getStandardHeader() ) configuration
-
-
-
Field Detail
-
header
protected java.lang.String header
-
idRecord
protected java.lang.String idRecord
-
defaultFormat
protected java.lang.String defaultFormat
-
generalOptions
protected java.lang.String generalOptions
-
columnNameFormat
protected java.lang.String columnNameFormat
-
addInfoFormat
protected java.lang.String addInfoFormat
-
colFormats
protected java.lang.String[] colFormats
-
isTranslated
protected boolean[] isTranslated
-
getsQuotes
protected boolean[] getsQuotes
-
httpHeader
protected java.lang.String httpHeader
-
-
Constructor Detail
-
ExcelSylkTemplate
public ExcelSylkTemplate(java.sql.ResultSetMetaData metaData, int rowCountIfKnown) throws java.sql.SQLException
Creates an Excel exported instance and exports all rows that occur in the metaData.
Important: Do not set rowCountIfKnown to a wrong value, because otherwise you will get an error message "Error in row 17".- Parameters:
metaData
- The meta data the column names will be taken from.rowCountIfKnown
- Set this to 0 if you do not know the exact number of rows the result set will contain. Otherwise set the row count here.- Throws:
java.sql.SQLException
-
ExcelSylkTemplate
public ExcelSylkTemplate(java.sql.ResultSetMetaData metaData, int rowCountIfKnown, java.util.List<ExcelSylkTemplate.ColumnMapping> orderedLogicalColumnNames) throws java.sql.SQLException
Creates an Excel exported instance.
Important: Do not set rowCountIfKnown to a wrong value, because otherwise you will get an error message "Error in row 17".- Parameters:
metaData
- The meta data the column names will be taken from.rowCountIfKnown
- Set this to 0 if you do not know the exact number of rows the result set will contain. Otherwise set the row count here.orderedLogicalColumnNames
- The list of column captions and database column names to be exported in exactly the list order. This can be null if the exported columns should be taken from the result set meta data.- Throws:
java.sql.SQLException
-
ExcelSylkTemplate
public ExcelSylkTemplate(java.sql.ResultSetMetaData metaData, int rowCountIfKnown, I18nDbResources i18nDbResources) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
ExcelSylkTemplate
public ExcelSylkTemplate(java.sql.ResultSetMetaData metaData, int rowCountIfKnown, java.util.List<ExcelSylkTemplate.ColumnMapping> orderedLogicalColumnNames, I18nDbResources i18nDbResources) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
-
Method Detail
-
writeStandardTable
public int writeStandardTable(java.io.PrintWriter output, java.sql.ResultSet resultSet, int nrRowsToFlush) throws java.io.IOException, java.sql.SQLException
write a the table with the 'standard' (see getStandardHeader() ) configuration- Parameters:
output
- stream to write onresultSet
- the result set to writenrRowsToFlush
- no. of resultset/excel rows after which stream is flushed- Throws:
java.io.IOException
java.sql.SQLException
-
writeHeader
protected void writeHeader(java.io.PrintWriter output) throws java.io.IOException
- Throws:
java.io.IOException
-
writeEndRecord
protected void writeEndRecord(java.io.PrintWriter output) throws java.io.IOException
- Throws:
java.io.IOException
-
writeColNamesRow
protected void writeColNamesRow(java.io.PrintWriter output) throws java.io.IOException
- Throws:
java.io.IOException
-
writeAddInfo
protected void writeAddInfo(java.io.PrintWriter output) throws java.io.IOException
- Throws:
java.io.IOException
-
getHttpHeader
public java.lang.String getHttpHeader()
-
setHttpHeader
public void setHttpHeader(java.lang.String httpHeader)
-
getContentRecord
protected java.lang.String getContentRecord(java.lang.String content, int colNr, java.lang.String extraData)
-
getDaysSince1900
public static java.lang.String getDaysSince1900(java.lang.String dateString) throws java.text.ParseException
- Throws:
java.text.ParseException
-
readColFormats
protected void readColFormats(java.sql.ResultSetMetaData metaData, java.util.List<de.businesscode.bcdui.wrs.export.ExcelSylkTemplate.ColumnMappingEx> orderedLogicalColumnNames) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
escapeColNamesForSylk
protected void escapeColNamesForSylk(java.util.List<de.businesscode.bcdui.wrs.export.ExcelSylkTemplate.ColumnMappingEx> orderedLogicalColumnNames)
-
getStandardHeader
protected java.lang.String getStandardHeader()
-
getColFormatDeclarations
protected java.lang.String getColFormatDeclarations()
-
writeRowsWoFormat
protected int writeRowsWoFormat(java.io.PrintWriter output, java.sql.ResultSet resultSet, int startRow, int nrRowsToFlush) throws java.io.IOException, java.sql.SQLException
- Throws:
java.io.IOException
java.sql.SQLException
-
writeErrorMessage
public static void writeErrorMessage(java.io.PrintWriter output, java.lang.String message) throws java.io.IOException
write the error message into the actual excel file contenttype from servlet must be "application/vnd.ms-excel"- Parameters:
output
- - where writemessage
- - string to write- Throws:
java.io.IOException
-
getHttpHeadersMap
public java.util.HashMap<java.lang.String,java.lang.String> getHttpHeadersMap()
get hash with wishContents of column with links- Returns:
- Returns the httpHeadersMap.
-
setHttpHeadersMap
public void setHttpHeadersMap(java.util.HashMap<java.lang.String,java.lang.String> headersMap)
set the hash with url string captions for the exel export- Parameters:
headersMap
- The httpHeadersMap to set.
-
getApplicationURL
public java.lang.String getApplicationURL()
-
getAddInfo
public java.lang.String getAddInfo()
-
setApplicationURL
public void setApplicationURL(java.lang.String applicationURL)
- Parameters:
applicationURL
- - like "http://localhost:8080/opms"
-
setAddInfo
public void setAddInfo(java.lang.String addInfo)
-
-