Convert a number to a letter in C for use in Microsoft Excel duplicate

0 votes

Ok so I am writing a method which accepts a 2d array as a parameter. I want to put this 2d array onto an Excel worksheet but I need to work out the final cell location. I can get the height easily enough like so:

var height = data.GetLength(1); //`data` is the name of my 2d array

This gives me my Y axis but it's not so easy to get my X axis. Obviously I can get the number like so:

var width = data.GetLength(0);

This gives me a number, which I want to convert to a letter. So, for example, 0 is A, 1 is B and so on until we get to 26 which goes back to A again. I am sure that there is a simple way to do this but I have a total mental block.

What would you do?


Feb 22 in Database by Edureka
• 9,320 points

1 answer to this question.

0 votes

If you are familiar with using formulas in Excel, it will not be a problem for you to employ the TEXT function.
 Add a helper column next to the column, And u need to enter the formula =TEXT(C2, "0"), now the number in the first cell will get converted. Now copy the formula across the column using the file handling option. Now in the helper column, you'll see changes in alignment. Now convert formulas to values in the helper column .copy cntrl+c and then crtl+alt+v for the special dialog box.Now select the values radio button in the pasted group. You are good to go

answered Feb 23 by Edureka
• 8,820 points

Related Questions In Database

0 votes
0 answers
0 votes
2 answers
0 votes
1 answer

Query to list number of records in each table in a database

Use the below code to list number of ...READ MORE

answered Oct 11, 2019 in Database by Omaiz
• 560 points
0 votes
1 answer

Generate a flat list of all excel cell formulas

Hello, you'll have to follow certain steps ...READ MORE

answered Feb 18 in Others by Edureka
• 8,820 points
0 votes
1 answer

Deleting duplicate rows in Excel using Epplus

You need to re-think this… the while ...READ MORE

answered Feb 23 in Database by Edureka
• 8,820 points
0 votes
3 answers

Trying to upload files using Selenium(C#)

You can try using Javascript Executor to ...READ MORE

answered Aug 23, 2019 in Selenium by Abha
• 28,100 points
0 votes
1 answer

Deploy my Windows 10 IOT core application locally!

Of course, you, can! That is, in ...READ MORE

answered Jul 17, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
0 votes
1 answer

How to convert a column number (e.g. 127) into an Excel column (e.g. AA)

If anyone needs to do this in ...READ MORE

answered Mar 30 in Database by Edureka
• 8,820 points
0 votes
1 answer

[Excel][VBA] How to draw a line in a graph?

Sub MakeChart() Dim x(20) ...READ MORE

answered Mar 24 in Database by Edureka
• 8,820 points
Send OTP
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP