Culture non invariant cause crash on save
See original GitHub issuedescription
running a simple create workbook, worksheet and save crashes for non invariant cultures.
repro
using System;
using System.Globalization;
using System.IO;
using System.Threading;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("it");
var wb = new ClosedXML.Excel.XLWorkbook();
var ws = wb.Worksheets.Add("test1");
wb.SaveAs(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test.xlsx"));
}
}
}
workaround
force a thread “en” culture on the workbook usage
stacktrace
System.ApplicationException occurred
HResult=0x80131600
Message=The attribute 'left' has invalid value '0.75'. The MaxExclusive constraint failed. The value must be less than 49. in /x:worksheet[1]/x:pageMargins[1]
The attribute 'right' has invalid value '0.75'. The MaxExclusive constraint failed. The value must be less than 49. in /x:worksheet[1]/x:pageMargins[1]
The attribute 'top' has invalid value '0.75'. The MaxExclusive constraint failed. The value must be less than 49. in /x:worksheet[1]/x:pageMargins[1]
The attribute 'footer' has invalid value '0.75'. The MaxExclusive constraint failed. The value must be less than 49. in /x:worksheet[1]/x:pageMargins[1]
Source=ClosedXML
StackTrace:
at ClosedXML.Excel.XLWorkbook.Validate(SpreadsheetDocument package) in C:\Git\ClosedXML\ClosedXML\Excel\XLWorkbook_Save.cs:line 90
at ClosedXML.Excel.XLWorkbook.CreatePackage(String filePath, SpreadsheetDocumentType spreadsheetDocumentType, Boolean validate) in C:\Git\ClosedXML\ClosedXML\Excel\XLWorkbook_Save.cs:line 105
at ClosedXML.Excel.XLWorkbook.SaveAs(String file, Boolean validate) in C:\Git\ClosedXML\ClosedXML\Excel\XLWorkbook.cs:line 479
at ClosedXML.Excel.XLWorkbook.SaveAs(String file) in C:\Git\ClosedXML\ClosedXML\Excel\XLWorkbook.cs:line 461
at ConsoleApp2.Program.Main(String[] args) in C:\Users\loren\Documents\Visual Studio 2017\Projects\ConsoleApp2\ConsoleApp2\Program.cs:line 18
notes
I think some double.Parse(str_val)
should replace with double.Parse(str_val, CultureInfo.InvariantCulture)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Saving causes CTD - No discernable pattern, and I have ...
To make it short, lately, whenever I try to manually save or quicksave, the sound cuts off and the game CTD... I was...
Read more >What would cause setting CurrentCulture to crash?
I agree with Alexei, InvariantCulture is a synthetic culture and is likely to cause trouble on a machine that boots XP. Changing the...
Read more >Skyrim Suddenly Crashes When Saving Game Everytime
The crashes are caused by a single plugin, a mod that I actually made myself. It's a merge of many different armors and...
Read more >Crash on save
The crashing when quicksaving can be caused by backup or sync programs, if they lock the original save.
Read more >no save / crashing fix - Crusader Kings II - GameFAQs
When the game exceeds alotted memory, it can't save anymore. ... Whatever your path, shifting culture is tricky but not impossible to achieve....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, the
develop
branch solves the problem for me.I removed my workaround and verified that downloading a spreadsheet in German gave the original error. I then rebuilt my solution with the locally-built DLL from
develop
instead of the NuGet package, and was able to download the spreadsheet okay.Thanks
The PR has been merged into the
develop
branch. I’d appreciate it if you could pull thedevelop
branch and check that it solves your issue. Thanks.