You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] - [Numeric Value (decimal) in dictionary causes Excel erros] #915
changed the title [-][BUG] - [Numeric Value (decimalk) in dictionary causes Excel erros][/-][+][BUG] - [Numeric Value (decimal) in dictionary causes Excel erros][/+]on Jan 13, 2026
value["Data"] = new Dictionnary<string, object>
{
...
["Altitude"] = 7.5, // double value from another object in real world but bug is present using these value
....
}
In Excel Template I use {{Data.Altitude}}
Opening the result, Excel gives me an error. The value is here but as string not number.
Debugging the code I saw that the value passed is "7,5" using coma not 7.5 using dot.
Using the ToString(CultureInfo.InvariantCulture) corrects the problem
My code used in strong type object as my scheme was static.
So Data was a List
The object value passed to MiniExcel was a Dictionary.
The dictionary contains 3 entries
The entry Data was a list of strong type object as the 1 other entries.
But now I have to manage a dynamic scheme (defined by configuration) so I can used a list of strong typed object.
So now entry Data of the dic is a Dictionary<string, obecjt>, so yes it's a dictionary inside the dictionary.
So I decide to use (as described in doc) a List of Dictionary<string, object>. Every double value causes Excel error if the value is not integer. Every value with decimals cause Excel error.
The problem is that the cell is type as a number but the value is not formatted so the Xml value is 7,5. Using the formatting used when it'a a strong type object resolve the issue.
All the rest of MiniExcel code handle dic in dic perfectly.
I don't understand why this formatting is used for strong type object but not for dateable or dictionary. Removing the test causes formatting for numeric value for every king of data source.
I'm not sure I understand your premise but it seems you were correct in identifying that the specific check is superfluous and prevents desired behaviour. I will make sure that removing it doesn't have unwanted side effects and if so it'll make the next release.
Activity
Guz-TsTech commentedon Jan 12, 2026
I got it working modifying source code as follow :
MiniExcel.Core / OpenXml / templates / OpenXmlTemplate.Impl.cs
Line 747 : if (/*!isDictOrTable && */TypeHelper.IsNumericType(type))
Removing test to detect if we process Dict or Table resolve the issue. The value is processed as numeric and everything is good.
I tried to push a pull request but I don't have the rights.
Regards.
Guillaume
[-][BUG] - [Numeric Value (decimalk) in dictionary causes Excel erros][/-][+][BUG] - [Numeric Value (decimal) in dictionary causes Excel erros][/+]michelebastione commentedon Jan 13, 2026
Please provide your template file and a sample of your code.
Guz-TsTech commentedon Jan 14, 2026
Hi,
My code is like that
var value = new Dictionary<string, object>();
....
value["Data"] = new Dictionnary<string, object>
{
...
["Altitude"] = 7.5, // double value from another object in real world but bug is present using these value
....
}
In Excel Template I use {{Data.Altitude}}
Opening the result, Excel gives me an error. The value is here but as string not number.
Debugging the code I saw that the value passed is "7,5" using coma not 7.5 using dot.
Using the ToString(CultureInfo.InvariantCulture) corrects the problem
michelebastione commentedon Jan 14, 2026
If I undersand correctly what you're trying to do, your code should actually follow this structure:
You can also use strongly typed objects if you prefer:
The important bit is that you use a collection of objects for your dictionary values, not other dictionaries.
Guz-TsTech commentedon Jan 15, 2026
My code used in strong type object as my scheme was static.
So Data was a List
The object value passed to MiniExcel was a Dictionary.
The dictionary contains 3 entries
The entry Data was a list of strong type object as the 1 other entries.
But now I have to manage a dynamic scheme (defined by configuration) so I can used a list of strong typed object.
So now entry Data of the dic is a Dictionary<string, obecjt>, so yes it's a dictionary inside the dictionary.
So I decide to use (as described in doc) a List of Dictionary<string, object>. Every double value causes Excel error if the value is not integer. Every value with decimals cause Excel error.
The problem is that the cell is type as a number but the value is not formatted so the Xml value is 7,5. Using the formatting used when it'a a strong type object resolve the issue.
All the rest of MiniExcel code handle dic in dic perfectly.
I don't understand why this formatting is used for strong type object but not for dateable or dictionary. Removing the test causes formatting for numeric value for every king of data source.
Regards.
michelebastione commentedon Jan 15, 2026
I'm not sure I understand your premise but it seems you were correct in identifying that the specific check is superfluous and prevents desired behaviour. I will make sure that removing it doesn't have unwanted side effects and if so it'll make the next release.
Guz-TsTech commentedon Jan 16, 2026
Thanks a lot.
Using Dictionary permits to have "dynamic" scheme for exported data. So I use it.
Hope there is no reason and no unwanted side effects.
Regards