1

I use LinqToExcel in my application for a while now and has been working like a charm.

But I'm facing a problem reading currency strings from Excel.

I can't post images yet, but the value in excel is 9999 formated like 9.999,00 (pt-BR)

Local in my machine LinqToExcel reads this value just fine(9999) and I can convert it to decimal.

But on the IIS server that has a en-US culture it reads this same value as 9,999.00, so when I try to convert is to decimal I get an exception.

Is there a way to set the default culture for LinqToExcel or something like that? Because I don't want to replace the , and . it's just too ugly.

I'm using C# VS2013.

4

1 回答 1

0

实际上问题是 excel 的第一行都是空字符串,所以如果用户将这些字段留空,LinqToExcel 将假定字符串作为这些列的类型,返回掩码输入(9.999,00)而不是整数值(9999) .

解决方法是在保存/关闭文件时使用 excel 文件中的 VBA 宏将空字符串替换为 0(零)。

于 2015-08-05T16:02:21.857 回答