Load CSV document with options
Leave feedback
GroupDocs.Conversion provides CsvLoadOptions 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:
const loadOptions = new groupdocs.conversion.CsvLoadOptions()
loadOptions.setConvertDateTimeData(true)
loadOptions.setConvertNumericData(true)
const outputPath = "ConvertCsvByConvertingDateTimeAndNumericData.pdf"
const converter = new groupdocs.conversion.Converter("sample.csv", loadOptions)
const convertOptions = new groupdocs.conversion.PdfConvertOptions()
console.log(`CSV document converted successfully to ${outputPath} (converting dateTime & numeric data)`)
converter.convert(outputPath, convertOptions)
The following code snippet shows how to convert a CSV document and specify the delimiter:
const loadOptions = new groupdocs.conversion.CsvLoadOptions()
loadOptions.setSeparator(",")
const outputPath = `ConvertCsvBySpecifyingDelimiter.pdf`
const converter = new groupdocs.conversion.Converter("sample.csv", loadOptions)
const convertOptions = new groupdocs.conversion.PdfConvertOptions()
console.log(`CSV document converted successfully to ${outputPath} (specifying delimiter)`)
converter.convert(outputPath, convertOptions)
The following code snippet shows how to convert a CSV document and specify the encoding:
const loadOptions = new groupdocs.conversion.CsvLoadOptions()
loadOptions.setEncoding("Shift_JIS")
const outputPath = `ConvertCsvBySpecifyingEncoding.pdf`
const converter = new groupdocs.conversion.Converter("sample.csv", loadOptions)
const convertOptions = new groupdocs.conversion.PdfConvertOptions()
console.log(`CSV document converted successfully to ${outputPath} (encoding specified)`)
converter.convert(outputPath, convertOptions)
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.