Start by downloading VSTO (Visual Studio Tools for Office) , this will allow you to create a C # Excel add-in add-in.
In Visual Studio, when you create a new project, you will see Office, and you can select Excel from it.
Start at this point, as soon as you do this, you can come back and ask more specific questions.
Some useful tips when working with Excel.
Select active sheet:
Excel.Worksheet sheet = this.Application.ActiveSheet as Excel.Worksheet;
To select a specific range (in this case, A1 - B5):
Excel.Range range = sheet.get_Range("A1", "B5") as Excel.Range;
Set a value for the entire range:
range.Value2 = 2; //will set every cell in A1 through B5 to 2
You can get values ββfrom a range in a 2-dimensional array, for example:
object[,] values = range.Value2 as object[,]; //this will return an multidimensional array representing rows and cols //as you see in the range. in this case the array is filed with "2"
Then you can change the values ββin the whole array and apply back to the range:
values[2, 2] = 4; //will change the value to 4 in row 2, col 2 of the *range* range.Value2 = values; //set back the whole range to the array
You can use this method to simultaneously update the entire range by first preparing the array and then setting it to the range values.
To get a value from a specific cell in your range (to set a value is the same thing, but vice versa).
Excel.Range cell = range.Cells[1,1] as Excel.Range; //this will take the cell from row 1, cell 1. if you used array this would be values[1,1] string value = (cell.Value2 ?? "").ToString();
This will allow you to perform basic tasks in Excel, you can set values ββand get values ββand select ranges. If you have a more specific question, please come back.
Remember that arrays coming from Excel are based on 1st, not based on zero.