We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Dynamically assign the next column letter


I have just started looking at Aspose Cells for .NET and got stumped with my first worksheet.
I created a worksheet with around 30 columns and I have hard coded each column letter. I realised that I missed a couple of important columns which should appear in column B and C. It then hit me that I will now have to manually set all the columns again. I now realise that I should store the column letter in a variable. Is there a way to get the next letter so this can occur dynamically?

cell = cells[$“A{cnt}”];

            cell = cells[$"B{cnt}"];
            //date of birth
            cell = cells[$"C{cnt}"];

and so on…

Thanks in advance,


You may use the CellsHelper.CellIndexToName(row, column) function to achieve this functionality. Please visit this link for more details about it.

int row = 3;
int column = 5;
string name = Aspose.Cells.CellsHelper.CellIndexToName(row, column);
Console.WriteLine("Cell name: {0}", name);

This is most helpful. Thank you.


You are welcome.