public ExcelSheet(WorksheetPart part, IExcelValueConverter valueConverter) { if (part == null) { throw new ArgumentNullException(nameof(part)); } _valueConverter = valueConverter ?? throw new ArgumentNullException(nameof(valueConverter)); _writer = OpenXmlWriter.Create(part); _writer.WriteStartElement(new Worksheet()); _writer.WriteStartElement(new SheetData()); }
public ExcelDocument(Stream stream, IExcelValueConverter valueConverter) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } _valueConverter = valueConverter ?? throw new ArgumentNullException(nameof(valueConverter)); _document = SpreadsheetDocument.Create(stream, SpreadsheetDocumentType.Workbook); _document.AddPart(_document.AddWorkbookPart()); _document.WorkbookPart.Workbook = new Workbook { Sheets = new Sheets() }; }
/// <summary> /// Constructs a new <see cref="ExcelDocumentFactory"/> with a custom value converter. /// </summary> /// <param name="valueConverter">The custom value converter.</param> public ExcelDocumentFactory(IExcelValueConverter valueConverter) { _valueConverter = valueConverter ?? throw new ArgumentNullException(nameof(valueConverter)); }
/// <summary> /// Constructs a new <see cref="ExcelDocumentFactory"/> instance with the default value converter. /// </summary> public ExcelDocumentFactory() { _valueConverter = new DefaultExcelValueConverter(CultureInfo.InvariantCulture, "O"); }