From 0d13405a1ba3ddc6dc1fd24d1aed88b6e8d998ba Mon Sep 17 00:00:00 2001 From: Michele Bastione Date: Mon, 23 Nov 2026 18:18:20 +0100 Subject: [PATCH 1/2] Moved configuration types to separate files into the Configuration folder --- src/MiniExcel.OpenXml/Writer/OpenXmlWriter.cs | 2 +- src/MiniExcel/Configuration.cs | 23 ------------------- .../Configuration/CsvConfiguration.cs | 11 +++++++++ src/MiniExcel/Configuration/IConfiguration.cs | 6 +++++ .../Configuration/OpenXmlConfiguration.cs | 4 ++++ 5 files changed, 22 insertions(+), 24 deletions(-) delete mode 100644 src/MiniExcel/Configuration.cs create mode 100644 src/MiniExcel/Configuration/CsvConfiguration.cs create mode 100644 src/MiniExcel/Configuration/IConfiguration.cs create mode 100644 src/MiniExcel/Configuration/OpenXmlConfiguration.cs diff --git a/src/MiniExcel.OpenXml/Writer/OpenXmlWriter.cs b/src/MiniExcel.OpenXml/Writer/OpenXmlWriter.cs index a63de2cf..9f8c5978 100644 --- a/src/MiniExcel.OpenXml/Writer/OpenXmlWriter.cs +++ b/src/MiniExcel.OpenXml/Writer/OpenXmlWriter.cs @@ -457,7 +457,7 @@ private async Task WriteCellAsync(MiniExcelStreamWriter writer, int rowIndex, in if (_configuration.EnableWriteNullValueCell && valueIsNull) { - await writer.WriteAsync(WorksheetXml.EmptyCell(columnReference, DefaultCellStyleIndex), cancellationToken).ConfigureAwait(false); + await writer.WriteAsync(WorksheetXml.EmptyCell(columnReference, RegularCellStyleIndex), cancellationToken).ConfigureAwait(false); return; } diff --git a/src/MiniExcel/Configuration.cs b/src/MiniExcel/Configuration.cs deleted file mode 100644 index e525b36f..00000000 --- a/src/MiniExcel/Configuration.cs +++ /dev/null @@ -1,23 +0,0 @@ -using MiniExcelLib.Core; - -namespace MiniExcelLibs -{ - public interface IConfiguration : IMiniExcelConfiguration; -} - -namespace MiniExcelLibs.OpenXml -{ - public sealed class OpenXmlConfiguration : MiniExcelLib.OpenXml.OpenXmlConfiguration, IConfiguration; -} - -namespace MiniExcelLibs.Csv -{ - public sealed class CsvConfiguration : MiniExcelLib.Csv.CsvConfiguration, IConfiguration - { - public bool ReadEmptyStringAsNull - { - get => ReadEmptyFieldsAsDefault; - set => ReadEmptyFieldsAsDefault = value; - } - } -} diff --git a/src/MiniExcel/Configuration/CsvConfiguration.cs b/src/MiniExcel/Configuration/CsvConfiguration.cs new file mode 100644 index 00000000..06637d88 --- /dev/null +++ b/src/MiniExcel/Configuration/CsvConfiguration.cs @@ -0,0 +1,11 @@ +// ReSharper disable once CheckNamespace +namespace MiniExcelLibs.Csv; + +public sealed class CsvConfiguration : MiniExcelLib.Csv.CsvConfiguration, IConfiguration +{ + public bool ReadEmptyStringAsNull + { + get => ReadEmptyFieldsAsDefault; + set => ReadEmptyFieldsAsDefault = value; + } +} diff --git a/src/MiniExcel/Configuration/IConfiguration.cs b/src/MiniExcel/Configuration/IConfiguration.cs new file mode 100644 index 00000000..c45d6e04 --- /dev/null +++ b/src/MiniExcel/Configuration/IConfiguration.cs @@ -0,0 +1,6 @@ +using MiniExcelLib.Core; + +// ReSharper disable once CheckNamespace +namespace MiniExcelLibs; + +public interface IConfiguration : IMiniExcelConfiguration; diff --git a/src/MiniExcel/Configuration/OpenXmlConfiguration.cs b/src/MiniExcel/Configuration/OpenXmlConfiguration.cs new file mode 100644 index 00000000..feb8304d --- /dev/null +++ b/src/MiniExcel/Configuration/OpenXmlConfiguration.cs @@ -0,0 +1,4 @@ +// ReSharper disable once CheckNamespace +namespace MiniExcelLibs.OpenXml; + +public sealed class OpenXmlConfiguration : MiniExcelLib.OpenXml.OpenXmlConfiguration, IConfiguration; From abf9efa366d24a4c3234e0b63037093742cd14ee Mon Sep 17 00:00:00 2001 From: Michele Bastione Date: Mon, 23 Nov 2026 18:44:51 +0100 Subject: [PATCH 2/2] Added missing facade configuration types These missing types prevented a seamless transition between v1.x and v2.0; they have been added, the namesake properties hidden with the `new` keyword and their implementation logic crafted so that they override the base ones without user intervention. --- src/MiniExcel.OpenXml/Writer/OpenXmlWriter.cs | 2 +- .../Configuration/OpenXmlConfiguration.cs | 91 ++++++++++++++++++- 2 files changed, 91 insertions(+), 2 deletions(-) diff --git a/src/MiniExcel.OpenXml/Writer/OpenXmlWriter.cs b/src/MiniExcel.OpenXml/Writer/OpenXmlWriter.cs index 9f8c5978..a63de2cf 100644 --- a/src/MiniExcel.OpenXml/Writer/OpenXmlWriter.cs +++ b/src/MiniExcel.OpenXml/Writer/OpenXmlWriter.cs @@ -457,7 +457,7 @@ private async Task WriteCellAsync(MiniExcelStreamWriter writer, int rowIndex, in if (_configuration.EnableWriteNullValueCell && valueIsNull) { - await writer.WriteAsync(WorksheetXml.EmptyCell(columnReference, RegularCellStyleIndex), cancellationToken).ConfigureAwait(false); + await writer.WriteAsync(WorksheetXml.EmptyCell(columnReference, DefaultCellStyleIndex), cancellationToken).ConfigureAwait(false); return; } diff --git a/src/MiniExcel/Configuration/OpenXmlConfiguration.cs b/src/MiniExcel/Configuration/OpenXmlConfiguration.cs index feb8304d..0923ee80 100644 --- a/src/MiniExcel/Configuration/OpenXmlConfiguration.cs +++ b/src/MiniExcel/Configuration/OpenXmlConfiguration.cs @@ -1,4 +1,93 @@ // ReSharper disable once CheckNamespace namespace MiniExcelLibs.OpenXml; -public sealed class OpenXmlConfiguration : MiniExcelLib.OpenXml.OpenXmlConfiguration, IConfiguration; +public sealed class OpenXmlConfiguration : MiniExcelLib.OpenXml.OpenXmlConfiguration, IConfiguration +{ + public new TableStyles TableStyles + { + get => base.TableStyles switch + { + MiniExcelLib.OpenXml.TableStyles.Default => TableStyles.Default, + _ => TableStyles.None + }; + set => base.TableStyles = value switch + { + TableStyles.Default => MiniExcelLib.OpenXml.TableStyles.Default, + _ => MiniExcelLib.OpenXml.TableStyles.None + }; + } +} + +public sealed class OpenXmlStyleOptions : MiniExcelLib.OpenXml.Styles.OpenXmlStyleOptions +{ + public new HorizontalCellAlignment HorizontalAlignment + { + get => base.HorizontalAlignment switch + { + MiniExcelLib.Core.Enums.HorizontalCellAlignment.Right => HorizontalCellAlignment.Right, + MiniExcelLib.Core.Enums.HorizontalCellAlignment.Center => HorizontalCellAlignment.Center, + _ => HorizontalCellAlignment.Left, + }; + set => base.HorizontalAlignment = value switch + { + HorizontalCellAlignment.Right => MiniExcelLib.Core.Enums.HorizontalCellAlignment.Right, + HorizontalCellAlignment.Center => MiniExcelLib.Core.Enums.HorizontalCellAlignment.Center, + _ => MiniExcelLib.Core.Enums.HorizontalCellAlignment.Left + }; + } + + public new VerticalCellAlignment VerticalAlignment + { + get => base.VerticalAlignment switch + { + MiniExcelLib.Core.Enums.VerticalCellAlignment.Top => VerticalCellAlignment.Top, + MiniExcelLib.Core.Enums.VerticalCellAlignment.Center => VerticalCellAlignment.Center, + _ => VerticalCellAlignment.Bottom + }; + set => base.VerticalAlignment = value switch + { + VerticalCellAlignment.Top => MiniExcelLib.Core.Enums.VerticalCellAlignment.Top, + VerticalCellAlignment.Center => MiniExcelLib.Core.Enums.VerticalCellAlignment.Center, + _ => MiniExcelLib.Core.Enums.VerticalCellAlignment.Bottom + }; + } +} + +public sealed class OpenXmlHeaderStyle : MiniExcelLib.OpenXml.Styles.OpenXmlHeaderStyle +{ + public new HorizontalCellAlignment HorizontalAlignment + { + get => base.HorizontalAlignment switch + { + MiniExcelLib.Core.Enums.HorizontalCellAlignment.Right => HorizontalCellAlignment.Right, + MiniExcelLib.Core.Enums.HorizontalCellAlignment.Center => HorizontalCellAlignment.Center, + _ => HorizontalCellAlignment.Left + }; + set => base.HorizontalAlignment = value switch + { + HorizontalCellAlignment.Right => MiniExcelLib.Core.Enums.HorizontalCellAlignment.Right, + HorizontalCellAlignment.Center => MiniExcelLib.Core.Enums.HorizontalCellAlignment.Center, + _ => MiniExcelLib.Core.Enums.HorizontalCellAlignment.Left + }; + } + + public new VerticalCellAlignment VerticalAlignment + { + get => base.VerticalAlignment switch + { + MiniExcelLib.Core.Enums.VerticalCellAlignment.Top => VerticalCellAlignment.Top, + MiniExcelLib.Core.Enums.VerticalCellAlignment.Center => VerticalCellAlignment.Center, + _ => VerticalCellAlignment.Bottom + }; + set => base.VerticalAlignment = value switch + { + VerticalCellAlignment.Top => MiniExcelLib.Core.Enums.VerticalCellAlignment.Top, + VerticalCellAlignment.Center => MiniExcelLib.Core.Enums.VerticalCellAlignment.Center, + _ => MiniExcelLib.Core.Enums.VerticalCellAlignment.Bottom + }; + } +} + +public enum TableStyles { None, Default } +public enum HorizontalCellAlignment { Left, Center, Right } +public enum VerticalCellAlignment { Bottom, Center, Top }