adams.data.io.output
Class ExcelSpreadSheetWriter

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.data.io.output.AbstractSpreadSheetWriter
              extended by adams.data.io.output.AbstractSpreadSheetWriterWithMissingValueSupport
                  extended by adams.data.io.output.ExcelSpreadSheetWriter
All Implemented Interfaces:
adams.core.Debuggable, adams.core.Destroyable, adams.core.option.OptionHandler, adams.core.SizeOfHandler, Serializable

public class ExcelSpreadSheetWriter
extends AbstractSpreadSheetWriterWithMissingValueSupport

Writes MS Excel files.

Valid options are:

-D <int> (property: debugLevel)
    The greater the number the more additional info the scheme may output to
    the console (0 = off).
    default: 0
    minimum: 0
 
-missing <java.lang.String> (property: missingValue)
    The placeholder for missing values.
    default:
 

Version:
$Revision: 6317 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Field Summary
static String FILE_EXTENSION
          the binary file extension.
static String FILE_EXTENSION_OOXML
          the OOXML file extension.
protected  boolean m_WriteOOXML
          whether to write OOXML instead of binary Excel files (latter is default).
 
Fields inherited from class adams.data.io.output.AbstractSpreadSheetWriterWithMissingValueSupport
m_MissingValue
 
Fields inherited from class adams.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Constructor Summary
ExcelSpreadSheetWriter()
           
 
Method Summary
protected  boolean doWrite(adams.data.spreadsheet.SpreadSheet content, OutputStream out)
          Performs the actual writing.
 String getFormatDescription()
          Returns a string describing the format (used in the file chooser).
 String[] getFormatExtensions()
          Returns the extension(s) of the format.
protected  boolean getUseOutputStream()
          Returns whether to write to an OutputStream rather than a Writer.
 boolean getWriteOOXML()
          Returns whether OOXML files are generated instead of binary Excel files.
 String globalInfo()
          Returns a string describing the object.
 void setWriteOOXML(boolean value)
          Sets whether to use OOXML instead of binary Excel files.
 boolean write(adams.data.spreadsheet.SpreadSheet content, String filename)
          Writes the spreadsheet in CSV format to the given file.
 
Methods inherited from class adams.data.io.output.AbstractSpreadSheetWriterWithMissingValueSupport
defineOptions, getDefaultMissingValue, getMissingValue, missingValueTipText, setMissingValue
 
Methods inherited from class adams.data.io.output.AbstractSpreadSheetWriter
doWrite, getWriters, write, write, write
 
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, debug, debug, debugLevelTipText, destroy, finishInit, getDebugLevel, getOptionManager, initialize, isDebugOn, newOptionManager, reset, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut, sizeOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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).

Constructor Detail

ExcelSpreadSheetWriter

public ExcelSpreadSheetWriter()
Method Detail

globalInfo

public String globalInfo()
Returns a string describing the object.

Specified by:
globalInfo in class adams.core.option.AbstractOptionHandler
Returns:
a description suitable for displaying in the gui

getFormatDescription

public String getFormatDescription()
Returns a string describing the format (used in the file chooser).

Specified by:
getFormatDescription in class AbstractSpreadSheetWriter
Returns:
a description suitable for displaying in the file chooser

getFormatExtensions

public String[] getFormatExtensions()
Returns the extension(s) of the format.

Specified by:
getFormatExtensions in class AbstractSpreadSheetWriter
Returns:
the extension (without the dot!)

getUseOutputStream

protected boolean getUseOutputStream()
Returns whether to write to an OutputStream rather than a Writer.

Specified by:
getUseOutputStream in class AbstractSpreadSheetWriter
Returns:
true if to write to an OutputStream

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

write

public boolean write(adams.data.spreadsheet.SpreadSheet content,
                     String filename)
Writes the spreadsheet in CSV format to the given file.

Overrides:
write in class AbstractSpreadSheetWriter
Parameters:
content - the spreadsheet to write
filename - the file to write the spreadsheet to
Returns:
true if successfully written

doWrite

protected boolean doWrite(adams.data.spreadsheet.SpreadSheet content,
                          OutputStream out)
Performs the actual writing. The caller must ensure that the writer gets closed.

Overrides:
doWrite in class AbstractSpreadSheetWriter
Parameters:
content - the spreadsheet to write
out - the writer to write the spreadsheet to
Returns:
true if successfully written


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.