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?

Thanks

Feb 22, 2022 in Database by Edureka
• 13,690 points
803 views

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, 2022 by gaurav
• 23,260 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
1,416 views
0 votes
1 answer
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, 2022 in Others by gaurav
• 23,260 points
533 views
0 votes
1 answer

Deleting duplicate rows in Excel using Epplus

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

answered Feb 23, 2022 in Database by gaurav
• 23,260 points
1,427 views
0 votes
1 answer

Export DataTable to Excel File

Add Interop References. First we need to ...READ MORE

answered Jun 9, 2022 in JQuery by gaurav
• 23,260 points
746 views
0 votes
0 answers

Best way to reverse a string

I recently had to develop a string ...READ MORE

Jun 11, 2022 in C# by krishna
• 2,820 points
564 views
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, 2022 in Database by gaurav
• 23,260 points
998 views
0 votes
1 answer

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

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

answered Mar 24, 2022 in Database by gaurav
• 23,260 points
1,992 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP