Skip to content

Commit 1178c19

Browse files
Release v3.0..0-rc.5
1 parent 38897ab commit 1178c19

File tree

20 files changed

+211
-146
lines changed

20 files changed

+211
-146
lines changed

Changelog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## v3.0.0-rc.5
44

55
---
6-
Release Date: **22.12.2025**
6+
Release Date: **04.01.2026**
77

88
- Added explicit operator for Address to convert from string to Address (string can be cast to address explicitly)
99
- Added implicit operator for Range to convert from string to Range (string can be cast to range implicitly)
@@ -13,7 +13,10 @@ Release Date: **22.12.2025**
1313
- ThemeColor (Color, defined by theme elements)
1414
- SystemColor (Color, defined by system colors)
1515
- AutoColor (automatic color, no value / dummy class)
16+
- Changed the type of `Font.ColorValue` from string to Color (can be sRGB/ARGB, Indexed, Theme, System or Auto)
17+
- Removed the property `Font.ColorTheme`, since only relevant for theme colors. The value is now handled by `Font.ColorValue`, in case of a ThemeColor
1618
- Re-implementation of the Fill class to use the new Color class for color representation of the foreground and background colors (indexed property removed)
19+
- Removed the property `Fill.IndexedColor`, since only relevant for Indexed colors. The value is now handled by `Fill.ForegroundColor` or `Fill.BackgroundColor`, in case of a IndexedColor
1720
- Added implicit operator for Fill to create a fill color by a string (RGB or ARGB value)
1821
- Added implicit operator for Fill to create a fill color by an integer (indexed color value)
1922
- Changed internal handling of text cell values

MigrationGuide.md

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,23 @@ The following guide lists all necessary changes, as well as changed behaviors of
125125
- The property `Row` is now read-only (immutable). To change the property, a new Address object has to be created
126126
- The property `Column` is now read-only (immutable). To change the property, a new Address object has to be created
127127
- The property `Type` is now read-only (immutable). To change the property, a new Address object has to be created
128+
- An Address object can now be de defined by an explicit cast (implicit casting was not realized due to potential issues with object comparison). Example:
129+
```cs
130+
sting addressString = "A15";
131+
Address address = (Address)addressString;
132+
```
128133

129134
---
130135

131136
### Range (struct)
132137

133138
- The property `StartAddress` is now read-only (immutable). To change the property, a new Range object has to be created
134139
- The property `EndAddress` is now read-only (immutable). To change the property, a new Range object has to be created
135-
140+
- A Range object can now be de defined by an implicit cast using a string. Example:
141+
```cs
142+
Range range = "A2:D15";
143+
```
144+
136145
---
137146

138147
### Styles
@@ -197,7 +206,37 @@ ApplicationDefined, ANSI, Default, Symbols, Mac, ShiftJIS, Hangul, Johab, GBK, B
197206
// ApplicableDefined is usually ignored, and Default may be used instead
198207
```
199208

200-
- The property `Font.ColorScheme` was changed from type `int` to the enum `Theme.ColorSchemeElement`. The value has to be replaced by one of the available values (See **Theme section** ). The initialization default value is `Theme.ColorSchemeElement.light1`.
209+
- The property `Font.ColorValue` was changed from type `string ` to the new `Color` class (namespace `NanoXLSX.Colors`). The new Color class can represent an RGB, ARGB, system, theme or indexed color. However, there are also implicit conversions. See the Color class documentation for more details. Usage examples:
210+
```cs
211+
Font font = new Font();
212+
font.ColorValue = Color.CreateIndexed(IndexedColor.Value.Yellow);
213+
214+
// Different examples with other color types
215+
216+
Font font2 = new Font();
217+
font.ColorValue = Color.CreateRgb("FF00FF00"); // ARGB
218+
219+
Font font3 = new Font();
220+
font3.ColorValue = Color.CreateTheme(Theme.ColorSchemeElement.Accent1, 0.5f); // Theme color with tint
221+
222+
// Implicit creation of specific color from a string (ARGB):
223+
Font font4 = new Font();
224+
font4.ColorValue = "FF00FF00"; // Implicit conversion to SrgbColor
225+
226+
// Implicit creation of font from an int (indexed color):
227+
Font font5 = new Font();
228+
Font font5.ColorValue = IndexedColor.Value.Black; // Implicit conversion to IndexedColor as background
229+
230+
// Implicit creation of specific color from an int (color index):
231+
Font font6 = new Font();
232+
font6.ColorValue = 63; // Implicit conversion to IndexedColor
233+
234+
// Implicit creation of specific color from an enum value (color index):
235+
Font font7 = new Font();
236+
font7.ColorValue = IndexedColor.Value.Magenta; // Implicit conversion to IndexedColor enum value
237+
```
238+
239+
- The property `Font.ColorTheme` was completely removed. This value is only relevant, if the property `Font.ColorValue` is of the type `ThemeColor`. All references are to be removed.
201240
- The property `Font.VerticalAlign` was changed from type `Font.VerticalAlignValue` to the enum `Font.VerticalTextAlignValue`. Only the enum name has to be changed (see below):
202241
- The enum `Font.VerticalAlignValue` was renamed to `Font.VerticalTextAlignValue`. The available values remain unchanged
203242

@@ -262,7 +301,7 @@ Fill was completely overhauled in version 3.0.0, to support more flexible color
262301
- The static method `Fill.ValidateColr(string,bool, bool)` was moved to the utils class `Validators.ValidateColr(string,bool, bool)` in namespace `NanoXLSX.Utils`. The class has to be changed in the code, but the method signature remains unchanged.
263302
- The property `Fill.BackgroundColor` was changed from type `string` to the new `Color` class (namespace `NanoXLSX.Colors`). The new Color class can represent an RGB, ARGB, system, theme or indexed color. See the Color class documentation for more details.
264303
- The property `Fill.ForegroundColor` was changed from type `string` to the new `Color` class (namespace `NanoXLSX.Colors`). The new Color class can represent an RGB, ARGB, system, theme or indexed color. See the Color class documentation for more details.
265-
- The property `IndexedColor` was removed and is now part of the new `Color` class, applied to `BackgroundColor` and `ForegroundColor`. In the `Color` class, there is a property `IndexedColor` that holds an object of the type `IndexedColor` (namespace `NanoXLSX.Themes`). The original `int` value has to be replaced by one of the available enum values in the class `IndexedColor`. Usage example:
304+
- The property `IndexedColor` was removed and is now part of the new `Color` class, applied to `BackgroundColor` and `ForegroundColor`. In the `Color` class, there is a property `IndexedColor` that holds an object of the type `IndexedColor` (namespace `NanoXLSX.Themes`). The original `int` value has to be replaced by one of the available enum values in the class `IndexedColor`. However, there are also implicit conversions. See the Color class documentation for more details. Usage examples:
266305

267306
```csharp
268307
Fill fill = new Fill();
@@ -278,21 +317,21 @@ fill3.ForegroundColor = Color.CreateTheme(Theme.ColorSchemeElement.Accent1, 0.5f
278317
// Implicit creation of fill from a string (ARGB):
279318
Fill fill4 = "FF00FF00"; // Implicit conversion to SrgbColor as foreground
280319
281-
// Implicit creation of fill from a int (indexed color):
320+
// Implicit creation of fill from an int (indexed color):
282321
Fill fill5 = IndexedColor.Value.Red2; // Implicit conversion to IndexedColor as foreground
283322
284-
// Implicit creation of fill from a int (indexed color):
285-
Fill fill6 = 64; // Implicit conversion to IndexedColor as foreground, ising the index number
323+
// Implicit creation of fill from an int (indexed color):
324+
Fill fill6 = 64; // Implicit conversion to IndexedColor as foreground, using the index number
286325
287326
// Implicit creation of specific color from a string (ARGB):
288327
Fill fill7 = new Fill();
289328
fill7.ForegroundColor = "FF00FF00"; // Implicit conversion to SrgbColor
290329
291-
// Implicit creation of fill from a int (indexed color):
330+
// Implicit creation of fill from an int (indexed color):
292331
Fill fill8 = new Fill();
293332
Fill fill8.BackgroundColor = IndexedColor.Value.Black; // Implicit conversion to IndexedColor as background
294333
295-
// Implicit creation of specific color from a int (color index):
334+
// Implicit creation of specific color from an int (color index):
296335
Fill fill9 = new Fill();
297336
fill9.BackgroundColor = 63; // Implicit conversion to IndexedColor
298337
```

NanoXLSX.Core/Changelog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
## v3.0.0-rc.3
44

55
---
6-
Release Date: **11.12.2025**
6+
Release Date: **04.01.2026**
77

88
- Internal change of structured text handling
9+
- Formal change of the `Color` and `ThemeColor` classes
10+
- Removed the property `ColorTheme` from the `Font` class
11+
- Changed the type of the property `ColorVlaue` of the Font class from `string` to `Color` (namespace `NanoXLES.Colors`)
912

1013

1114
## v3.0.0-rc.2

NanoXLSX.Core/Colors/Color.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ public enum ColorType
7272
public SystemColor SystemColor { get; private set; }
7373

7474
/// <summary>
75-
/// Optional tint value for colors (-1.0 to 1.0)
75+
/// Optional tint value for colors (-1.0 to 1.0), mainly for theme colors
7676
/// Positive values lighten, negative values darken
7777
/// </summary>
78+
/// \remark <remarks>Although tint is generally specified for all color types, according to the OOXML specifications, it seems only to have an effect on colors of the type <see cref="ThemeColor"/>. Therefore, the value is also not written on any color except ThemeColor</remarks>
7879
public double? Tint { get; set; }
7980

8081
/// <summary>
@@ -340,6 +341,29 @@ public static implicit operator Color(IndexedColor.Value colorIndex)
340341
return CreateIndexed(colorIndex);
341342
}
342343

344+
/// <summary>
345+
/// String representation od a Color instance
346+
/// </summary>
347+
/// <returns>String value</returns>
348+
public override string ToString()
349+
{
350+
switch (Type)
351+
{
352+
case ColorType.Rgb:
353+
return "RGBColor:" + RgbColor.StringValue;
354+
case ColorType.Indexed:
355+
return "IndexedColor:" + IndexedColor.StringValue;
356+
case ColorType.Theme:
357+
return "ThemeColor:" + ThemeColor.StringValue;
358+
case ColorType.System:
359+
return "SystemColor:" + SystemColor.StringValue;
360+
case ColorType.Auto:
361+
return "Auto-Color";
362+
default:
363+
return "Undefined Color";
364+
}
365+
}
366+
343367

344368
/// <summary>
345369
/// Determines whether the specified object is equal to the current object

NanoXLSX.Core/Colors/ThemeColor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class ThemeColor : ITypedColor<Theme.ColorSchemeElement>
2222
public Theme.ColorSchemeElement ColorValue { get; set; }
2323

2424
/// <summary>
25-
/// Gets the internal OOXML string value of the enum, defined in <see cref="ColorValue"/>
25+
/// Gets the internal, numeric OOXML string value of the enum, defined in <see cref="ColorValue"/>
2626
/// </summary>
2727
public string StringValue
2828
{

NanoXLSX.Core/Styles/Font.cs

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
using System.Collections.Generic;
99
using System.Text;
10+
using NanoXLSX.Colors;
1011
using NanoXLSX.Exceptions;
1112
using NanoXLSX.Utils;
1213
using static NanoXLSX.Themes.Theme;
@@ -303,56 +304,21 @@ public enum FontFamilyValue
303304
/// Gets or sets the char set of the Font
304305
/// </summary>
305306
[Append]
306-
//TODO: v3> Refactor to enum according to specs
307-
// OOXML: Chp.19.2.1.13
308307
public CharsetValue Charset { get; set; } = CharsetValue.Default;
309308

310309
/// <summary>
311-
/// Gets or sets the font color theme, represented by a color scheme
312-
/// </summary>
313-
[Append]
314-
//TODO: v3> Reference to Theming
315-
//OOXML: Chp.18.8.3 and 20.1.6.2
316-
public ColorSchemeElement ColorTheme
317-
{
318-
get => colorTheme;
319-
set
320-
{
321-
if (value == null)
322-
{
323-
throw new StyleException("A color theme cannot be null");
324-
}
325-
colorTheme = value;
326-
}
327-
}
328-
/// <summary>
329-
/// Gets or sets the color code of the font color. The value is expressed as hex string with the format AARRGGBB. AA (Alpha) is usually FF. If set, the value will be cast to upper case
310+
/// Gets or sets the color code of the font color. The value is an instance of <see cref="Color"/>
330311
/// To omit the color, an empty string can be set. Empty is also default.
331312
/// </summary>
332-
/// <exception cref="StyleException">Throws a StyleException if the passed ARGB value is not valid</exception>
333313
[Append]
334-
public string ColorValue
314+
public Color ColorValue
335315
{
336-
get => colorValue;
337-
set
338-
{
339-
Validators.ValidateColor(value, true, true);
340-
if (value != null)
341-
{
342-
colorValue = ParserUtils.ToUpper(value);
343-
}
344-
else
345-
{
346-
colorValue = value;
347-
}
348-
}
316+
get; set;
349317
}
350318
/// <summary>
351319
/// Gets or sets the font family (Default is 2 = Swiss)
352320
/// </summary>
353321
[Append]
354-
//TODO: v3> Refactor to enum according to specs (18.18.94)
355-
//OOXML: Chp.18.8.18 and 18.18.94
356322
public FontFamilyValue Family { get; set; }
357323
/// <summary>
358324
/// Gets whether the font is equal to the default font
@@ -367,7 +333,6 @@ public bool IsDefaultFont
367333
}
368334
}
369335

370-
371336
/// <summary>
372337
/// Gets or sets the font name (Default is Calibri)
373338
/// </summary>
@@ -417,13 +382,13 @@ public float Size
417382
/// <summary>
418383
/// Default constructor
419384
/// </summary>
385+
/// \remark <remarks>When using the default constructor, an object of type <see cref="Color"/> with the type <see cref="Color.ColorType.None"/> will be created for the property <see cref="Font.ColorValue"/>. To set a font color, the property has to be updated with a new value</remarks>
420386
public Font()
421387
{
422388
size = DefaultFontSize;
423389
Name = DefaultFontName;
424390
Family = DefaultFontFamily;
425-
ColorTheme = ColorSchemeElement.Light1;
426-
ColorValue = string.Empty;
391+
ColorValue = Color.CreateNone();// Default is none
427392
Scheme = DefaultFontScheme;
428393
VerticalAlign = DefaultVerticalAlign;
429394
}
@@ -464,7 +429,6 @@ public override string ToString()
464429
sb.Append("\"Font\": {\n");
465430
AddPropertyAsJson(sb, "Bold", Bold);
466431
AddPropertyAsJson(sb, "Charset", Charset);
467-
AddPropertyAsJson(sb, "ColorTheme", ColorTheme);
468432
AddPropertyAsJson(sb, "ColorValue", ColorValue);
469433
AddPropertyAsJson(sb, "VerticalAlign", VerticalAlign);
470434
AddPropertyAsJson(sb, "Family", Family);
@@ -489,7 +453,6 @@ public override AbstractStyle Copy()
489453
{
490454
Bold = Bold,
491455
Charset = Charset,
492-
ColorTheme = ColorTheme,
493456
ColorValue = ColorValue,
494457
VerticalAlign = VerticalAlign,
495458
Family = Family,
@@ -517,8 +480,7 @@ public override int GetHashCode()
517480
hashCode = hashCode * -1521134295 + size.GetHashCode();
518481
hashCode = hashCode * -1521134295 + Bold.GetHashCode();
519482
hashCode = hashCode * -1521134295 + Charset.GetHashCode();
520-
hashCode = hashCode * -1521134295 + ColorTheme.GetHashCode();
521-
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(ColorValue);
483+
hashCode = hashCode * -1521134295 + EqualityComparer<Color>.Default.GetHashCode(ColorValue);
522484
hashCode = hashCode * -1521134295 + Family.GetHashCode();
523485
hashCode = hashCode * -1521134295 + Italic.GetHashCode();
524486
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Name);
@@ -544,7 +506,6 @@ public override bool Equals(object obj)
544506
Strike == font.Strike &&
545507
Underline == font.Underline &&
546508
Charset == font.Charset &&
547-
ColorTheme == font.ColorTheme &&
548509
ColorValue == font.ColorValue &&
549510
Family == font.Family &&
550511
Name == font.Name &&

NanoXLSX.Core/Utils/Validators.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private static string ValidateColorInternal(string hexCode, bool useAlpha, bool
6161
{
6262
return null;
6363
}
64-
return "The color expression was null or empty";
64+
return "The color expression cannot be null or empty";
6565
}
6666

6767
int length = useAlpha ? 8 : 6;

NanoXLSX.Reader/Changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## v3.0.0-rc.3
44

55
---
6-
Release Date: **21.12.2025**
6+
Release Date: **04.01.2026**
77

88
- Changed handling of colors in the style reader (Fills) to consider:
99
- sRGB colors (RGB / ARGB)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
PROJECT_NUMBER = 3.0.0-rc.2
1+
PROJECT_NUMBER = 3.0.0-rc.3

0 commit comments

Comments
 (0)