Package io.keikai.axyra.sheets.io
Class CsvOptions
java.lang.Object
io.keikai.axyra.sheets.io.CsvOptions
Options for
Workbook.saveCsv(path, options). The defaults write
what a plain save("x.csv") writes, which is what Excel's Save As CSV
writes: the active sheet, comma-separated, as display text.
The file is UTF-8 and every row ends with CR LF. CsvOptions.Values.RAW
changes only numeric cells; text, booleans and errors are written the same
way in both modes. A formula cell writes its cached value, never the formula.
wb.saveCsv(path, CsvOptions.create().sheet("Payments").values(CsvOptions.Values.RAW));
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhat a numeric cell is written as; seevalues(Values). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CsvOptionscreate()Options with the defaults: the active sheet, comma, display text, no byte-order mark.charThe field separator.delimiter(char delimiter) Sets the field separator.sheet(int index) Chooses the sheet to write by 0-based index, replacing a choice by name.Chooses the sheet to write by name, compared ignoring case as Excel does.intThe chosen 0-based sheet index, or -1 when the sheet is the default or chosen bysheetName().The sheet name, ornullwhen not chosen by name.booleanutf8Bom()Whether the file starts with a UTF-8 byte-order mark.utf8Bom(boolean bom) Starts the file with a UTF-8 byte-order mark (true), as Excel's "CSV UTF-8" format does.values()How numeric cells are written.values(CsvOptions.Values values) Chooses how numeric cells are written: display text (CsvOptions.Values.FORMATTED, the default) or stored values (CsvOptions.Values.RAW).
-
Constructor Details
-
CsvOptions
public CsvOptions()
-
-
Method Details
-
create
Options with the defaults: the active sheet, comma, display text, no byte-order mark.- Returns:
- new options
-
sheet
Chooses the sheet to write by 0-based index, replacing a choice by name. Default: the active sheet, or the first visible sheet when the active sheet is hidden. A hidden sheet chosen by index is written.- Parameters:
index- the 0-based sheet index; an index past the last sheet makessaveCsvthrowAxyraException- Returns:
- these options
- Throws:
IllegalArgumentException- ifindexis negative
-
sheet
Chooses the sheet to write by name, compared ignoring case as Excel does. Replaces a choice by index.- Parameters:
name- the sheet name; an unknown name makessaveCsvthrowIllegalArgumentException- Returns:
- these options
- Throws:
NullPointerException- ifnameisnull
-
delimiter
Sets the field separator. Default','. A field that contains the separator, a double quote, a tab or a line break is quoted.- Parameters:
delimiter- one ASCII character, e.g.';'or'\t'- Returns:
- these options
- Throws:
IllegalArgumentException- ifdelimiteris not ASCII, or is a double quote, CR or LF
-
values
Chooses how numeric cells are written: display text (CsvOptions.Values.FORMATTED, the default) or stored values (CsvOptions.Values.RAW).- Parameters:
values- the mode- Returns:
- these options
- Throws:
NullPointerException- ifvaluesisnull
-
utf8Bom
Starts the file with a UTF-8 byte-order mark (true), as Excel's "CSV UTF-8" format does. Defaultfalse.- Parameters:
bom-trueto write the mark- Returns:
- these options
-
sheetIndex
public int sheetIndex()The chosen 0-based sheet index, or -1 when the sheet is the default or chosen bysheetName(). -
sheetName
The sheet name, ornullwhen not chosen by name. -
delimiter
public char delimiter()The field separator. -
values
How numeric cells are written. -
utf8Bom
public boolean utf8Bom()Whether the file starts with a UTF-8 byte-order mark.
-