|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object olg.csv.base.AbstractSheetWriter olg.csv.base.ods.ODSWriter
public class ODSWriter
ODS Writer based on ODFDOM API.
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 | |
---|---|
private AbstractParser<List<String>> |
cellParser
The cell parser. |
private int |
currentLine
the current row index to add. |
private boolean |
emptyingCell
Indicates if document cells must be emptied. |
private boolean |
emtpyingRow
Indicates if document rows must be emptied. useful when the rows to add do not follow. |
private static org.slf4j.Logger |
LOGGER
Class logger. |
private OutputStream |
out
the out stream. |
private File |
outFile
the out file. |
private org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument |
outputDocument
the ODS Document. |
private boolean |
overridding
Indicates if the document must be overriding. true if the table was not created but opened in an existing document. |
private int |
size
the size of the rows to add in the document. |
private org.odftoolkit.odfdom.doc.table.OdfTable |
table
the table on which write rows. |
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!). |
private void |
createNewDocument(String sheetName)
Create a new ODS Document with a table. |
private org.odftoolkit.odfdom.doc.table.OdfTable |
createSheet(String sheetName)
creates a new empty ODF table in the ODS document. |
private void |
emptyCells(org.odftoolkit.odfdom.doc.table.OdfTableRow row,
int begin,
int end,
boolean force)
empties cells of a row if overriding and emptyingRow are true. |
private void |
emptyRows(int num)
empties rows. |
private void |
insertCell(org.odftoolkit.odfdom.doc.table.OdfTableCell odfCell,
String value)
set a value on a cell. |
private void |
insertCell(org.odftoolkit.odfdom.doc.table.OdfTableRow odfRow,
Cell cell)
copy a cell in a row. |
private void |
insertCellAtNum(org.odftoolkit.odfdom.doc.table.OdfTableRow odfRow,
int num,
String value)
Insert a cell in a row. |
private void |
loadDocument(String sheetName)
Opens the outFile as an ODS Document and opens the table or create the table if not existe in the document. |
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 |
Field Detail |
---|
private static final org.slf4j.Logger LOGGER
private org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument outputDocument
private org.odftoolkit.odfdom.doc.table.OdfTable table
private File outFile
private OutputStream out
private final AbstractParser<List<String>> cellParser
private int size
private int currentLine
private final boolean emptyingCell
private final boolean emtpyingRow
private boolean overridding
Constructor Detail |
---|
public ODSWriter(File outFile, ODSSettings settings) throws IOException
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
IOException
- if an errors occurs on file opening.public ODSWriter(OutputStream out, ODSSettings settings) throws IOException
out
- writes a new ODSDocument on it.settings
- ODS Settings
IOException
- if unable to create a new ODS DocumentMethod Detail |
---|
public void close()
public void addRow(Row 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.
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.public void addLine(String[] values)
IWriter.addRow(Row)
had been used first.
Throws a WriterException when line size differs from initial size.
values
- the row. Must be not null
with length >0. .private org.odftoolkit.odfdom.doc.table.OdfTable createSheet(String sheetName)
sheetName
- the table name.
private void createNewDocument(String sheetName) throws IOException
sheetName
- the name of the table
IOException
- if unable to create new ODS Documentprivate void loadDocument(String sheetName) throws IOException
sheetName
- the name of the table to open.
IOException
- if unable to load the document.private void insertCell(org.odftoolkit.odfdom.doc.table.OdfTableRow odfRow, Cell cell)
odfRow
- the rowcell
- the cell to insertprivate void insertCellAtNum(org.odftoolkit.odfdom.doc.table.OdfTableRow odfRow, int num, String value)
odfRow
- the rownum
- the column num after beginAtColumnvalue
- the cell valueprivate void insertCell(org.odftoolkit.odfdom.doc.table.OdfTableCell odfCell, String value)
odfCell
- the cellvalue
- the value.private void emptyRows(int num)
num
- the number of rows to empty. begins at currentLine after
beginAtRow value.private void emptyCells(org.odftoolkit.odfdom.doc.table.OdfTableRow row, int begin, int end, boolean force)
row
- the rowbegin
- first column (include) after beginAtColumn value.end
- last column (exclude) after beginAtColumn value.force
- if true bypass overriding and emptyingCell condition.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |