Search code examples
c#asp.netasp.net-mvcepplus

Saving EPPlus worksheet throws on error when switching CurrentCulture


We have a module which creates an excel file and the user can download it. We are using EPPlus v4.0.1.1 to build the files. There's a bug on when the user has a culture code of "tr-TR", the saveAs is throwing an error of "An item with the same key has already been added". But when we switch it back to "en-US", it saves successfully.

Below is the code:

var currentCulture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR"); 
var tempStream = new FileStream(Path.GetTempFileName(), FileMode.Create, FileAccess.ReadWrite, FileShare.Read, 4096, FileOptions.DeleteOnClose);
package.SaveAs(tempStream);

Can someone help me why is EPPlus throwing an error on this particular culture? Thanks.


Solution

  • I have fixed the error by updating the EPPlus version from 4.0.1.1 to 4.1.0.0

    Apparently, the older version cannot handle some of the culture (in my scenario, tr-TR).