I have this code (this is a simplified version of real code) that opens excel and sets the cell value. Please note that I am in Italy and we use , instead . to separate decimal digits. This means that I use 12.5 in the code, but the result of ToString() on this number is "12.5", and Excel also shows 12.5.
using Xls = Microsoft.Office.Interop.Excel; public class ExcelTest { public static void Test { object hmissing = System.Reflection.Missing.Value;
Everything worked fine for many years using .NET 2, but when I try to switch to .NET 4, Excel warns me that the number was saved as text.
Please note that I know that just avoiding the call to ToString () fixes the problem, but in the real case I am dealing with an outdated application that wants to store several types of data in excel, both in banquets and in user-defined ones, and ToString ( ) was the only method available for all of these types that would give the desired result in Excel without having to check the type and decide whether to pass set_Value.
So I am not asking how to change my code to make it work. I'm just trying to understand why the behavior is different in the two versions of the framework. This is very important because I would prefer to change my code before users find out that something is wrong.
Francesco baruchelli
source share