Hope you can help.
I'm looking for a way to build an excel sheet range by just passing in some parameters. My method is as follows:
private void TableCellformatting(int rowStart, int rowEnd, char colStart, char colEnd)
{
char temp;
StringBuilder s = new StringBuilder();
excelSheetRange = null;
for (int i = rowStart; i <= rowEnd; i++)
{
temp = colStart;
while (temp <= colEnd)
{
if (s.Length > 0)
s.Append(", ");
s.Append(string.Format("{0}{1}", temp.ToString(), i));
temp++;
}
}
excelSheetRange = excelSheet.get_Range(s.ToString());
excelSheetRange.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
}
This runs ok until the excelSheet.get_Range part is called. When I pass in the cell numbers manually, I have to do it like this:
get_Range("A1", "A2" etc...)
Any ideas if this is even possible, or if there is another way?
Thanks!