I am trying to remove the commas from a cell inside an excel file, but I have the situation that after applying my code in the first row everything is fine I have no problem, but from the second round my code will be stop completely in the same line where I apply the Replace()
.
It does not send me an error, it simply freezes and stays loaded forever.
The variable x13
I use to know that if the method removes the commas and everything goes well, until the next round of for
.
Application excel = new Application();
Workbook sheet = excel.Workbooks.Open(filePatht);
Worksheet x = excel.ActiveSheet as Worksheet;
_Worksheet xlWorksheet = sheet.Sheets[1];
Excel.Range xlRange = xlWorksheet.UsedRange;
int rowCount = xlRange.Rows.Count;
for (int ix = 12; ix < rowCount; ix++) {
//xlRange.NumberFormat = "0.00";
xlRange.Cells[ix, 2].Replace(",", " ");
var x13 = xlRange.Cells[ix, 2].Text;
xlRange.Cells[ix, 4].NumberFormat = "0.00";
xlRange.Cells[ix, 5].NumberFormat = "0.00";
xlRange.Cells[ix, 6].NumberFormat = "0.00";
}
sheet.Save();