Table of Contents

Method SetValue

Namespace
DocWright.Formats.Xlsx
Assembly
DocWright.Formats.Xlsx.dll

SetValue(int, int, XlsxCellValue)

Sets a cell's value. A formula the cell had is removed; its format is kept.

public void SetValue(int row, int column, XlsxCellValue value)

Parameters

row int

The one-based row, 1 to 1,048,576.

column int

The one-based column, 1 to 16,384.

value XlsxCellValue

The value. Blank empties the cell and keeps it for its format.

Remarks

The cell need not exist. Text is written into the cell itself (an inline string); the workbook's shared string table is not rewritten. A date is a number: give the cell a date number format with SetStyle(int, int, XlsxCellStyle) for it to show as one.

Nothing is calculated. Formulas that depend on the cell keep the results the file had until the workbook is opened in an application that calculates; the saved workbook asks for that calculation.

Exceptions

ArgumentOutOfRangeException

The row or the column is outside the worksheet grid.

ArgumentException

The value is text longer than the 32,767 characters a cell holds.

InvalidOperationException

The sheet is not a worksheet.

UnsupportedFeatureException

The cell is part of an array formula entered over several cells, or is a header or totals cell of a table.

InvalidDocumentException

The sheet's part is malformed.

SetValue(string, XlsxCellValue)

Sets a cell's value by its reference. See SetValue(int, int, XlsxCellValue).

public void SetValue(string reference, XlsxCellValue value)

Parameters

reference string

The reference, such as B4.

value XlsxCellValue

The value.

Exceptions

ArgumentNullException

reference is null.

ArgumentException

reference is not a cell reference inside the worksheet grid, or the value is too long.

InvalidOperationException

The sheet is not a worksheet.

UnsupportedFeatureException

The cell is part of an array formula entered over several cells, or is a header or totals cell of a table.

InvalidDocumentException

The sheet's part is malformed.