Load CSV document with options
Leave feedback
On this page
GroupDocs.Conversion provides CsvLoadOptions to give you control over how the source CSV document will be processed. The following options could be set:
Option | Description |
---|---|
Separator | Specifies the delimiter |
AllColumnsInOnePagePerSheet | If true, all column content from a single sheet will be converted into a single page. The width of paper size of page setup will be ignored, while keeping the rest of page settings. |
AutoFitRows | If enabled, automatically adjusts the content of all rows while converting. |
CheckExcelRestriction | Whether to check restrictions of Excel file when modifying cell objects. |
ConvertNumericData | Specifies that strings with digits should be parsed as numbers |
ConvertDateTimeData | Specifies that date/time strings should be detected and parsed to DateTime |
ConvertRange | Defines a specific range of cells to be converted. For example: “D1:F8” |
CultureInfo | Specifies system culture info at the time file is loaded. |
DefaultFont | Specify the default font to use if a document font is missing. |
Encoding | Specifies the encoding to be used during loading |
FontSubstitutes | Substitute specific fonts from the source spreadsheet. |
HasFormula | Specifies that if text starts with “=” it should be parsed as a formula |
HideComments | Specify if the comments from the source spreadsheet should be hidden during conversion. |
IsMultiEncoded | If true, this means that the document contains several encodings. |
OnePagePerSheet | If specified, each spreadsheet will be converted into a single page. |
OptimizePdfSize | If enabled, optimizes the resulting PDF for smaller file size, rather than for better print quality. |
Password | Defines a password to unlock a protected document. |
SheetIndexes | Defines the indexes of the particular sheets to be converted. |
Sheets | Defines the names of the particular sheets to be converted. |
ShowGridLines | Specify if the grid lines should be visible. |
ShowHiddenSheets | Specify if the hidden sheets should be included in the converted document. |
SkipEmptyRowsAndColumns | Specify if empty rows and columns should be ignored. |
The following code snippet shows how to convert a CSV document and control the way the date/time and numeric data have been processed:
Contracts.Func<LoadOptions> getLoadOptions = () => new CsvLoadOptions
{
ConvertDateTimeData = true,
ConvertNumericData = true
};
using (Converter converter = new Converter("sample.csv", getLoadOptions))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("converted.pdf", options);
}
The following code snippet shows how to convert a CSV document and specify the delimiter:
Contracts.Func<LoadOptions> getLoadOptions = () => new CsvLoadOptions
{
Separator = ','
};
using (Converter converter = new Converter("sample.csv", getLoadOptions))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("converted.pdf", options);
}
The following code snippet shows how to convert a CSV document and specify the encoding:
Contracts.Func<LoadOptions> getLoadOptions = () => new CsvLoadOptions
{
Encoding = Encoding.GetEncoding("shift_jis")
};
using (Converter converter = new Converter("sample.csv", getLoadOptions))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("converted.pdf", options);
}
To fit the row content of all rows while converting, set the AutoFitRows property to true
:
Contracts.Func<LoadOptions> getLoadOptions = () => new CsvLoadOptions
{
AutoFitRows = true
};
using (Converter converter = new Converter("sample.csv", getLoadOptions))
{
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.