Class DocxFormValue
- Namespace
- DocToolkit
- Assembly
- DocToolkit.Docx.dll
A value read from, or written into, a Word content control.
public sealed class DocxFormValue
- Inheritance
-
DocxFormValue
- Inherited Members
Remarks
This type exists to make one guarantee structural. The library beneath offers
WordContentControlPictureValue.FromFile(path), which reads the filesystem. This package
deliberately refuses to read local files for images — see AllowLocalImages, which is false
by default — so that route must not be reachable here either. There is therefore no picture
factory taking a path or a URI. A caller who wants a file on disk reads it themselves, in one
line, and the decision is visibly theirs.
Upstream models these values as object. A typed value is what turns that rule from
something a guard has to remember into something this API cannot express.
Properties
Bytes
The image content, for Picture.
public byte[]? Bytes { get; }
Property Value
- byte[]
Remarks
A copy, on the way in and on the way out. Without both, this sealed type with
getter-only properties would not actually be immutable: a caller who kept their array could
change what a value means after Validate had approved it and before Fill wrote
it, and a caller could mutate what a report reports by writing through this property.
Checked
Whether the box is ticked, for Checked.
public bool? Checked { get; }
Property Value
- bool?
Date
The date, for Date.
public DateTime? Date { get; }
Property Value
FileName
The image's file name, for Picture.
public string? FileName { get; }
Property Value
Kind
Which kind of value this is; which other properties are set follows from it.
public DocxFormValueKind Kind { get; }
Property Value
Text
public string? Text { get; }
Property Value
Methods
FromChecked(bool)
A check-box value.
public static DocxFormValue FromChecked(bool value)
Parameters
valueboolWhether the box is ticked.
Returns
FromChoice(string)
A drop-down or combo-box selection.
public static DocxFormValue FromChoice(string value)
Parameters
valuestringThe option to select.
Returns
Exceptions
- ArgumentNullException
valueis null.
FromDate(DateTime)
A date value.
public static DocxFormValue FromDate(DateTime value)
Parameters
valueDateTimeThe date to write.
Returns
FromPicture(byte[], string)
An image, from bytes. There is deliberately no overload taking a path — see the remarks on DocxFormValue.
public static DocxFormValue FromPicture(byte[] bytes, string fileName)
Parameters
Returns
Exceptions
- ArgumentNullException
bytesorfileNameis null.- ArgumentException
bytesis empty, orfileNameis blank.
FromText(string)
A plain-text value.
public static DocxFormValue FromText(string value)
Parameters
valuestringThe text to write.
Returns
Exceptions
- ArgumentNullException
valueis null.