Load CSV document with options
Leave feedback
GroupDocs.Conversion provides the CsvLoadOptions class to give you control over how the source CSV document will be processed. The following options could be set:
- setSeparator specifies the delimiter.
- setIsMultiEncoded whether true, this 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 strings should be detected and parsed to DateTime.
- setEncoding specifies the encoding to be used during loading.
The following code snippet shows how to convert a CSV document and control the way the date/time and numeric data have been processed:
import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.options.convert.PdfConvertOptions;
import com.groupdocs.conversion.options.load.CsvLoadOptions;
...
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);
The following code snippet shows how to convert a CSV document and specify the delimiter:
import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.options.convert.PdfConvertOptions;
import com.groupdocs.conversion.options.load.CsvLoadOptions;
...
CsvLoadOptions loadOptions = new CsvLoadOptions();
loadOptions.setSeparator(',');
Converter converter = new Converter("sample.csv", loadOptions);
PdfConvertOptions options = new PdfConvertOptions();
converter.convert("converted.pdf", options);
The following code snippet shows how to convert a CSV document and specify the encoding:
import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.options.convert.PdfConvertOptions;
import com.groupdocs.conversion.options.load.CsvLoadOptions;
...
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);
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.