Package adams.data.io.output
Class ExcelSpreadSheetWriter
-
- All Implemented Interfaces:
AdditionalInformationHandler,Destroyable,GlobalInfoSupporter,EncodingSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,Stoppable,StoppableWithFeedback,MultiSheetSpreadSheetWriter,SpreadSheetWriter,SpreadSheetWriterWithFormulaSupport,Serializable
public class ExcelSpreadSheetWriter extends AbstractMultiSheetSpreadSheetWriterWithMissingValueSupport implements SpreadSheetWriterWithFormulaSupport
Writes MS Excel files.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-sheet-prefix <java.lang.String> (property: sheetPrefix) The prefix for sheet names. default: Sheet
-missing <java.lang.String> (property: missingValue) The placeholder for missing values. default:
-time-format <adams.data.DateFormatString> (property: timeFormat) The format for times. default: HH:mm:ss more: https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html
-date-format <adams.data.DateFormatString> (property: dateFormat) The format for dates. default: yyyy-MM-dd more: https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html
-datetime-format <adams.data.DateFormatString> (property: dateTimeFormat) The format for date/times. default: yyyy-MM-dd HH:mm:ss more: https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html
-output-as-displayed <boolean> (property: outputAsDisplayed) If enabled, cells are output as displayed, ie, results of formulas instead of the formulas. default: false
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class adams.data.io.output.AbstractSpreadSheetWriter
AbstractSpreadSheetWriter.OutputType
-
-
Field Summary
Fields Modifier and Type Field Description static StringFILE_EXTENSIONthe binary file extension.static StringFILE_EXTENSION_OOXMLthe OOXML file extension.protected DateFormatStringm_DateFormatthe format string for the dates.protected DateFormatStringm_DateTimeFormatthe format string for the date/times.protected booleanm_OutputAsDisplayedwhether to output the cells as displayed (disable to output formulas).protected DateFormatStringm_TimeFormatthe format string for the times.protected booleanm_WriteOOXMLwhether to write OOXML instead of binary Excel files (latter is default).-
Fields inherited from class adams.data.io.output.AbstractMultiSheetSpreadSheetWriterWithMissingValueSupport
m_MissingValue
-
Fields inherited from class adams.data.io.output.AbstractMultiSheetSpreadSheetWriter
m_SheetPrefix
-
Fields inherited from class adams.data.io.output.AbstractSpreadSheetWriter
m_Encoding, m_Stopped
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description ExcelSpreadSheetWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringdateFormatTipText()Returns the tip date for this property.StringdateTimeFormatTipText()Returns the tip date/time for this property.voiddefineOptions()Adds options to the internal list of options.protected booleandoWrite(SpreadSheet[] content, OutputStream out)Performs the actual writing.SpreadSheetReadergetCorrespondingReader()Returns, if available, the corresponding reader.DateFormatStringgetDateFormat()Returns the format for date columns.DateFormatStringgetDateTimeFormat()Returns the format for date/time columns.StringgetFormatDescription()Returns a string describing the format (used in the file chooser).String[]getFormatExtensions()Returns the extension(s) of the format.booleangetOutputAsDisplayed()Returns whether to output the cell content as displayed, ie, no formulas but the result of formulas.protected AbstractSpreadSheetWriter.OutputTypegetOutputType()Returns how the data is written.DateFormatStringgetTimeFormat()Returns the format for time columns.booleangetWriteOOXML()Returns whether OOXML files are generated instead of binary Excel files.StringglobalInfo()Returns a string describing the object.StringoutputAsDisplayedTipText()Returns the tip text for this property.protected voidpreWriteFile(String filename)Hook method before writing to a file.voidsetDateFormat(DateFormatString value)Sets the format for date columns.voidsetDateTimeFormat(DateFormatString value)Sets the format for date/time columns.voidsetOutputAsDisplayed(boolean value)Sets whether to output the cell content as displayed, ie, no formulas but the result of formulas.voidsetTimeFormat(DateFormatString value)Sets the format for time columns.voidsetWriteOOXML(boolean value)Sets whether to use OOXML instead of binary Excel files.StringtimeFormatTipText()Returns the tip time for this property.-
Methods inherited from class adams.data.io.output.AbstractMultiSheetSpreadSheetWriterWithMissingValueSupport
getDefaultMissingValue, getMissingValue, missingValueTipText, setMissingValue
-
Methods inherited from class adams.data.io.output.AbstractMultiSheetSpreadSheetWriter
canWriteMultiple, doWrite, doWrite, doWrite, doWrite, getDefaultSheetPrefix, getSheetPrefix, setSheetPrefix, sheetPrefixTipText, write, write, write, write
-
Methods inherited from class adams.data.io.output.AbstractSpreadSheetWriter
canCompress, doWrite, encodingTipText, getAdditionalInformation, getDefaultFormatExtension, getEncoding, getWriters, initialize, isStopped, reset, setEncoding, stopExecution, supportsCompressedOutput, write, write, write, write
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.Destroyable
destroy
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
Methods inherited from interface adams.data.io.output.SpreadSheetWriter
reset, write, write, write, write
-
Methods inherited from interface adams.core.Stoppable
stopExecution
-
Methods inherited from interface adams.core.StoppableWithFeedback
isStopped
-
-
-
-
Field Detail
-
FILE_EXTENSION
public static String FILE_EXTENSION
the binary file extension.
-
FILE_EXTENSION_OOXML
public static String FILE_EXTENSION_OOXML
the OOXML file extension.
-
m_WriteOOXML
protected boolean m_WriteOOXML
whether to write OOXML instead of binary Excel files (latter is default).
-
m_TimeFormat
protected DateFormatString m_TimeFormat
the format string for the times.
-
m_DateFormat
protected DateFormatString m_DateFormat
the format string for the dates.
-
m_DateTimeFormat
protected DateFormatString m_DateTimeFormat
the format string for the date/times.
-
m_OutputAsDisplayed
protected boolean m_OutputAsDisplayed
whether to output the cells as displayed (disable to output formulas).
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractMultiSheetSpreadSheetWriterWithMissingValueSupport
-
getFormatDescription
public String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescriptionin interfaceSpreadSheetWriter- Specified by:
getFormatDescriptionin classAbstractSpreadSheetWriter- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensionsin interfaceSpreadSheetWriter- Specified by:
getFormatExtensionsin classAbstractSpreadSheetWriter- Returns:
- the extension (without the dot!)
-
getCorrespondingReader
public SpreadSheetReader getCorrespondingReader()
Returns, if available, the corresponding reader.- Specified by:
getCorrespondingReaderin interfaceSpreadSheetWriter- Returns:
- the reader, null if none available
-
getOutputType
protected AbstractSpreadSheetWriter.OutputType getOutputType()
Returns how the data is written.- Specified by:
getOutputTypein classAbstractSpreadSheetWriter- Returns:
- the type
-
setWriteOOXML
public void setWriteOOXML(boolean value)
Sets whether to use OOXML instead of binary Excel files.- Parameters:
value- if true OOXML files are generated
-
getWriteOOXML
public boolean getWriteOOXML()
Returns whether OOXML files are generated instead of binary Excel files.- Returns:
- true if OOXML files are generated
-
setTimeFormat
public void setTimeFormat(DateFormatString value)
Sets the format for time columns.- Parameters:
value- the format
-
getTimeFormat
public DateFormatString getTimeFormat()
Returns the format for time columns.- Returns:
- the format
-
timeFormatTipText
public String timeFormatTipText()
Returns the tip time for this property.- Returns:
- tip time for this property suitable for displaying in the gui
-
setDateFormat
public void setDateFormat(DateFormatString value)
Sets the format for date columns.- Parameters:
value- the format
-
getDateFormat
public DateFormatString getDateFormat()
Returns the format for date columns.- Returns:
- the format
-
dateFormatTipText
public String dateFormatTipText()
Returns the tip date for this property.- Returns:
- tip date for this property suitable for displaying in the gui
-
setDateTimeFormat
public void setDateTimeFormat(DateFormatString value)
Sets the format for date/time columns.- Parameters:
value- the format
-
getDateTimeFormat
public DateFormatString getDateTimeFormat()
Returns the format for date/time columns.- Returns:
- the format
-
dateTimeFormatTipText
public String dateTimeFormatTipText()
Returns the tip date/time for this property.- Returns:
- tip date for this property suitable for displaying in the gui
-
setOutputAsDisplayed
public void setOutputAsDisplayed(boolean value)
Sets whether to output the cell content as displayed, ie, no formulas but the result of formulas.- Specified by:
setOutputAsDisplayedin interfaceSpreadSheetWriterWithFormulaSupport- Parameters:
value- true if to output as displayed
-
getOutputAsDisplayed
public boolean getOutputAsDisplayed()
Returns whether to output the cell content as displayed, ie, no formulas but the result of formulas.- Specified by:
getOutputAsDisplayedin interfaceSpreadSheetWriterWithFormulaSupport- Returns:
- true if to output as displayed
-
outputAsDisplayedTipText
public String outputAsDisplayedTipText()
Returns the tip text for this property.- Specified by:
outputAsDisplayedTipTextin interfaceSpreadSheetWriterWithFormulaSupport- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
preWriteFile
protected void preWriteFile(String filename)
Hook method before writing to a file.- Overrides:
preWriteFilein classAbstractSpreadSheetWriter- Parameters:
filename- the filename to check
-
doWrite
protected boolean doWrite(SpreadSheet[] content, OutputStream out)
Performs the actual writing. The caller must ensure that the writer gets closed.- Overrides:
doWritein classAbstractMultiSheetSpreadSheetWriter- Parameters:
content- the spreadsheet to writeout- the writer to write the spreadsheet to- Returns:
- true if successfully written
-
-