I have an automation that takes data from different data sources, the problem is that there is some decimal data that it saves me as text.
How can I do so that I do not save these numbers as text?
this is what i have now
//Variables interop para excel, xlWorksheet es la hoja de excel.
String excel[100,100]; //Array bidimensional
/* Mapeo el excel a la matriz */
//Aquí habría código
/* Relleno la matriz con datos String */
//Aquí recogería información
/* Mapeo la matriz al excel */ <---- aquí empieza el problema
xlWorksheet.Cells[i, j] = Convert.ToDouble(excel[fila, columna]); <-- esto es String
Range r = (Range)xlWorksheet.Cells[fila, columna];
r.NumberFormat = "#0.00";
I have also tried with
r.NumberFormat = "#0,00";
What you should do is change the format of the cell (or column) in Excel, doing something like the following:
First, in the cell you must put the correct type of data:
And then you can select the type of format as in the following code: