public final class CsvSaveOptions extends SaveOptions
Following code demonstrates how to save ExcelCell values to CSV file format. ExcelCell value (numbers, dates, etc.) will be converted to string using specified culture.
CsvSaveOptions saveOptions = new CsvSaveOptions(CsvType.COMMA_DELIMITED);
saveOptions.setLocale(Locale.getDefault());
ef.save("Report.csv", saveOptions);
Constructor and Description |
---|
CsvSaveOptions(char separator)
Initializes a new instance of the
CsvSaveOptions class. |
CsvSaveOptions(CsvType csvType)
Initializes a new instance of the
CsvSaveOptions class. |
Modifier and Type | Method and Description |
---|---|
Charset |
getCharset()
Gets the charset for the CSV file.
|
String |
getContentType()
Gets the content-type for CSV file format:
"text/tab-separated-values; charset=" +
getCharset() }.name() if getType() is CsvType.TAB_DELIMITED , otherwise
"text/csv; charset=" + getCharset() }.name().
|
FileFormatLimitations |
getLimitations()
Gets limitations for saving to CSV file format.
|
Locale |
getLocale()
Gets the locale for the CSV file.
|
char |
getSeparator()
Gets character that serves as value delimiter.
|
Optional<CsvType> |
getType()
Gets value delimiter type, see
CsvType . |
boolean |
isAlwaysQuoteValues()
Gets a value indicating whether values in CSV file will always be quoted.
|
boolean |
isUseFormattedValues()
Gets a value indicating whether values in CSV file will be formatted using
number format . |
void |
setAlwaysQuoteValues(boolean alwaysQuoteValues)
Gets a value indicating whether values in CSV file will always be quoted.
|
void |
setCharset(Charset value)
Sets the charset for the CSV file.
|
void |
setLocale(Locale locale)
Sets the locale for the CSV file.
|
void |
setSeparator(char separator)
Sets character that serves as value delimiter.
|
void |
setType(CsvType type)
Sets value delimiter type, see
CsvType . |
void |
setUseFormattedValues(boolean useFormattedValues)
Sets a value indicating whether values in CSV file will be formatted using
number format . |
getCsvDefault, getHtmlDefault, getOdsDefault, getXlsDefault, getXlsxDefault
public CsvSaveOptions(char separator)
CsvSaveOptions
class.separator
- Character that will serve as value delimiter.public CsvSaveOptions(CsvType csvType)
CsvSaveOptions
class.csvType
- Value delimiter, CsvType
.public Charset getCharset()
public String getContentType()
getCharset()
}.name() if getType()
is CsvType.TAB_DELIMITED
, otherwisegetCharset()
}.name().getContentType
in class SaveOptions
public FileFormatLimitations getLimitations()
Integer.MAX_VALUE
Integer.MAX_VALUE
Integer.MAX_VALUE
Integer.MAX_VALUE
getLimitations
in class SaveOptions
public Locale getLocale()
public char getSeparator()
public boolean isAlwaysQuoteValues()
public boolean isUseFormattedValues()
number format
. Default value is false.public void setAlwaysQuoteValues(boolean alwaysQuoteValues)
public void setCharset(Charset value)
NullPointerException
- Value is set to null
.public void setLocale(Locale locale)
NullPointerException
- locale is set to null
.public void setSeparator(char separator)
IllegalArgumentException
- Value is set to quote '"' or new line '\n'.public void setType(CsvType type)
CsvType
.NullPointerException
- type is set to null
.public void setUseFormattedValues(boolean useFormattedValues)
number format
. Default value is false.© GemBox Ltd. — All rights reserved.