Interface IXlsxToCsvConverter
- Namespace
- DocToolkit.Extensions.DependencyInjection
- Assembly
- DocToolkit.Extensions.DependencyInjection.dll
Exports one sheet of a workbook as CSV (RFC 4180). Registered by AddDocToolkit(IServiceCollection, Action<DocToolkitOptions>?).
public interface IXlsxToCsvConverter
Remarks
The output does not depend on the machine's regional settings, and that is a correctness
requirement rather than a preference: ReadSheet(byte[], string)
renders a number through the current culture, which turns 1234.5 into 1234,5 on a
German machine - a decimal comma inside a comma-delimited file. Numbers are invariant, dates are
ISO 8601, and a formula cell exports its computed value.
One sheet, named explicitly. CSV has no concept of a workbook, so there is nothing sensible to do with the other sheets - SheetNames(byte[]) lists them.
Methods
Convert(byte[], string)
Exports sheetName as CSV.
string Convert(byte[] xlsx, string sheetName)
Parameters
Returns
Exceptions
- ArgumentNullException
xlsxis null.- ArgumentException
xlsxis empty, or the sheet name is blank.- DocumentConversionException
The workbook could not be opened, or the sheet does not exist.
ConvertAsync(Stream, string, CancellationToken)
Reads a workbook from source and exports sheetName as
CSV. source is read to its end and is not disposed, closed or sought.
Task<string> ConvertAsync(Stream source, string sheetName, CancellationToken ct = default)
Parameters
sourceStreamsheetNamestringctCancellationToken
Returns
Exceptions
- ArgumentNullException
sourceis null.- ArgumentException
sourceis not readable or held no bytes, or the sheet name is blank.- OperationCanceledException
ctwas cancelled.- DocumentConversionException
The workbook could not be opened, or the sheet does not exist.