0

I use C# .Net 4.0 to produce an excel workbook with NPOI. When I set us-EN as culture it works' fine, instead when I change the culture to it-IT I receive the following message:

Excel found unreadable content in '[filename].xls'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes.

When I click Yes, the excel file opens well. It happens with each version of excel. I use the following piece of code to change the culture and initialize the workbook:

   var culture = new CultureInfo("it-IT");
   Thread.CurrentThread.CurrentCulture = culture;
   Thread.CurrentThread.CurrentUICulture = culture;

   var xssfworkbook = new XSSFWorkbook();

Someone can help me? Thanks!

  • I suspect your excel spreadsheet has some invalid format data that doesn't support it-IT culture. Try to set the regional settings of your spreadsheet then. I have found a link which might help you. https://learn.microsoft.com/en-us/visualstudio/vsto/globalization-and-localization-of-excel-solutions?view=vs-2019 – Junius Nov 11 '19 at 21:51
  • Unfortunately the excel file is corrupted even if it's empty. Could be related with some other setting? – Sergio Gentile Nov 11 '19 at 22:02
  • Okay @Sergio Gentile, that doesn't sound good. Anyway, I was thinking maybe you could initialize your `XSSFWorkbook` before instantiating a `new CultureInfo()`. – Junius Nov 11 '19 at 22:18

0 Answers0