Load CSV document with options
GroupDocs.Conversion provides CsvLoadOptions to give you control over how source CSV document will be processed. The following options could be set:
- setSeparator - specifies the delimiter
- setIsMultiEncoded - if true, means that the document contains several encodings
- hasFormula - specifies that if text starts with “=” it should be parsed as a formula
- setConvertNumericData - specifies that strings with digits should be parsed as numbers
- setConvertDateTimeData - specifies that date/time string should be detected and parsed to DateTime
- setEncoding - specifies the encoding to be used during load
Control behavior of converting date/time and numeric data
The following code sample shows how to convert CSV document and control the way the date/time and numeric data have been processed:
CsvLoadOptions loadOptions = new CsvLoadOptions();
loadOptions.setConvertDateTimeData(true);
loadOptions.setConvertNumericData(true);
Converter converter = new Converter("sample.csv", loadOptions);
PdfConvertOptions options = new PdfConvertOptions();
converter.convert("converted.pdf", options);
Specify delimiter
The following code sample shows how to convert CSV document and specify the delimiter
CsvLoadOptions loadOptions = new CsvLoadOptions();
loadOptions.setSeparator(',');
Converter converter = new Converter("sample.csv", loadOptions);
PdfConvertOptions options = new PdfConvertOptions();
converter.convert("converted.pdf", options);
Specify encoding
The following code sample shows how to convert CSV document and specify the encoding
CsvLoadOptions loadOptions = new CsvLoadOptions();
loadOptions.setEncoding(java.nio.charset.Charset.forName("shift_jis"));
Converter converter = new Converter("sample.csv", loadOptions);
PdfConvertOptions options = new PdfConvertOptions();
converter.convert("converted.pdf", options);