From dad216fc0cbcbd732450a73fe189dd857d5bee32 Mon Sep 17 00:00:00 2001 From: sveinungf Date: Sat, 20 Jan 2024 21:58:38 +0100 Subject: [PATCH] Assign null string value in DataCell --- SpreadCheetah/DataCell.cs | 2 +- SpreadCheetah/SpreadsheetBuffer.cs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/SpreadCheetah/DataCell.cs b/SpreadCheetah/DataCell.cs index a9adbeb4..d14bb2b1 100644 --- a/SpreadCheetah/DataCell.cs +++ b/SpreadCheetah/DataCell.cs @@ -17,7 +17,7 @@ public readonly record struct DataCell /// public DataCell(string? value) { - StringValue = value ?? string.Empty; + StringValue = value; Type = value != null ? CellWriterType.String : CellWriterType.Null; } diff --git a/SpreadCheetah/SpreadsheetBuffer.cs b/SpreadCheetah/SpreadsheetBuffer.cs index ea9a43ad..35eed59e 100644 --- a/SpreadCheetah/SpreadsheetBuffer.cs +++ b/SpreadCheetah/SpreadsheetBuffer.cs @@ -129,6 +129,9 @@ public bool AppendFormatted(T value) public bool AppendFormatted(string? value) { + if (value is null) + return true; + if (XmlUtility.TryXmlEncodeToUtf8(value.AsSpan(), GetSpan(), out var bytesWritten)) { _pos += bytesWritten;