change cells with range.replace RRS feed

  • Pregunta

  • well I have a mini program changing all excel cells beginning with ='C:\, but I have a problem. I use range.replace for do this, but my program work wrong, because it don't change all the cells contain ='C:\, only change the first find it and I don't know for what reason.

    My code is :

    foreach (Excel.Worksheet sheet in xlWorkBook.Sheets)
                            string sheetName = sheet.Name;
                            //seleccion rango activo
                            range = sheet.UsedRange;
                            //leer las celdas
                            int rows = range.Rows.Count;
                            int cols = range.Columns.Count;
                            Excel.Range startCell = sheet.Cells[1, 1];
                            Excel.Range endCell = sheet.Cells[rows, cols];
                            sheet.Range["A1:J1000"].Replace(@"C:\", @"C:\Gestion\");
                            // liberar

    Alguna solución ? 

    martes, 18 de febrero de 2014 9:07

Todas las respuestas