olg.csv.base.ods
Class ODSWriter

java.lang.Object
  extended by olg.csv.base.AbstractSheetWriter
      extended by olg.csv.base.ods.ODSWriter
All Implemented Interfaces:
Closeable, IWriter

public class ODSWriter
extends AbstractSheetWriter

ODS Writer based on ODFDOM API.

Author:
Olivier Godineau

Nested Class Summary
static class ODSWriter.ODSParser
          This parser returns lines extracted from a string by interpreting \r, \n or \r\n as line breaks found in it.
 
Field Summary
 
Fields inherited from class olg.csv.base.AbstractSheetWriter
beginAtColumn, beginAtRow, sheetName, withHeaders
 
Constructor Summary
ODSWriter(File outFile, ODSSettings settings)
           
ODSWriter(OutputStream out, ODSSettings settings)
          Constructs ODSWriter with outputStream and Settings.
 
Method Summary
 void addLine(String[] values)
          Adds a row from the given String array.
 void addRow(Row row)
          Adds a row.
 void close()
          Close this stream and save the ODS Document to the file/stream and catch and log Exception if necessary. if the parent stream is provided and passed to its constructor by user, user must close it (close what you open!).
 
Methods inherited from class olg.csv.base.AbstractSheetWriter
getSheetName, isWithHeaders
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ODSWriter

public ODSWriter(File outFile,
                 ODSSettings settings)
          throws IOException
Parameters:
outFile - if outFile exists and contains sheet with specified sheetName, rewrites rows and cells in it. if sheetname sheet doesn't exists, creates it and writes on it. If outFile not exists, creates a new ODS File.
settings - the ODS Settings
Throws:
IOException - if an errors occurs on file opening.

ODSWriter

public ODSWriter(OutputStream out,
                 ODSSettings settings)
          throws IOException
Constructs ODSWriter with outputStream and Settings. Try to create a new ODS Document which will be saved

Parameters:
out - writes a new ODSDocument on it.
settings - ODS Settings
Throws:
IOException - if unable to create a new ODS Document
Method Detail

close

public void close()
Close this stream and save the ODS Document to the file/stream and catch and log Exception if necessary. if the parent stream is provided and passed to its constructor by user, user must close it (close what you open!).


addRow

public void addRow(Row row)
Adds a row.

The first row allows to define the size used along writing unless IWriter.addLine(String[]) had been used first.

Throws a WriterException when row size differs from initial size or row num is lesser than the expected next number line. Or if I/O error occurs during writing.

Parameters:
row - the row. It's possible to use a row with no cells. In this case, an empty line(a line wich all fields are null) is added. It's possible to use a row with a num greater than the expected number. In this case, empty lines are wroten as much as necessary. It's possible to use row which all cells are not specified. In this case the missing cells are added as empty cells. Must be not null with cells correctly ordered and size>0.

addLine

public void addLine(String[] values)
Adds a row from the given String array. The first time this method define the size ( as the given string array length) used along writing unless IWriter.addRow(Row) had been used first.

Throws a WriterException when line size differs from initial size.

Parameters:
values - the row. Must be not null with length >0. .


Copyright © 2014. All rights reserved.