In the version 4.1 following code throws exception:
```
ens = ep.Workbook.Styles.CreateNamedStyle("Test")
Dim bTestOK As Boolean = ens.Style.WrapText
ens.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center
Dim bTestNG As Boolean = ens.Style.WrapText
```
Here are the exception details.
```
=== System.ArgumentOutOfRangeException =========================
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
----------------------------
Source: mscorlib
----------------------------
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.Collections.Generic.List`1.get_Item(Int32 index)
at OfficeOpenXml.ExcelStyleCollection`1.get_Item(Int32 PositionID) in <path>\EPPlus\36\e1834888\ExcelStyleCollection`1.cs:line 30
at OfficeOpenXml.Style.ExcelStyle.get_WrapText() in <path>\EPPlus\52\de9556c8\ExcelStyle.cs:line 60
```
Each time the style is changing an internal hash key of all values is created for inventory of identical styles and stored in Id property.
For example
```
General|Calibri110FFFFNone|None0000|None00None00None00None00None00FalseFalse|Bottom|General|False|ContextDependent|1|False
```
The hash key includes XfId at the second to last location.
I think this could be a mistake and should not be a part of the hash key.
Workaround for the issue is to save and re-open the file before accessing attributes of the Named Styles.
```
ens = ep.Workbook.Styles.CreateNamedStyle("Test")
Dim bTestOK As Boolean = ens.Style.WrapText
ens.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center
Dim bTestNG As Boolean = ens.Style.WrapText
```
Here are the exception details.
```
=== System.ArgumentOutOfRangeException =========================
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
----------------------------
Source: mscorlib
----------------------------
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.Collections.Generic.List`1.get_Item(Int32 index)
at OfficeOpenXml.ExcelStyleCollection`1.get_Item(Int32 PositionID) in <path>\EPPlus\36\e1834888\ExcelStyleCollection`1.cs:line 30
at OfficeOpenXml.Style.ExcelStyle.get_WrapText() in <path>\EPPlus\52\de9556c8\ExcelStyle.cs:line 60
```
Each time the style is changing an internal hash key of all values is created for inventory of identical styles and stored in Id property.
For example
```
General|Calibri110FFFFNone|None0000|None00None00None00None00None00FalseFalse|Bottom|General|False|ContextDependent|1|False
```
The hash key includes XfId at the second to last location.
I think this could be a mistake and should not be a part of the hash key.
Workaround for the issue is to save and re-open the file before accessing attributes of the Named Styles.