Search code examples
c#exceldata-conversion

C# How can I convert an excel cells address in the following notation: "LetterNumber" to "Number, Number" and vice-versa?


How can I convert an excel cells address in the following notation: "LetterNumber" to "Number, Number" and vice-versa?


Solution

  • I'm trying to set the value of Worksheet.Cells[] but it does not except the "B3" kinds of values

    Worksheet.Range does:

    Worksheet.Range("A4").Value = "Foo";
    

    I would also advise you not to set one cell at a time if you can help it. Every call to Cells or Range in a slow interop call, so you'll get much better performance if you put your values in an array and set the value of an entire range in one shot:

    int[,] values;
    // fill values with integers
    Worksheet.Range("A1","D4") = values;