7

JavaScript Snippet – Convert Column Name To Number

 3 years ago
source link: https://cwestblog.com/2020/06/10/javascript-snippet-convert-column-name-to-number/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

On a rare occasion you may need to convert a column name from Excel or Google Sheets to a number. For example you may be seeing references to a random column such as D, G, BV, etc. but you don’t know how to represent it as a number. Instead of import a JavaScript library you can use plain old JavaScript. All you have to do is include this snippet in your code base and you will have access to your own toColumnNumber(…) function:

How To Use It

As you may have noticed the function is already documented. In addition, if you want direction you can check out this short video explaining how to use the function:

Examples

If you checked out the video you saw that there are two examples of how to call this function. These examples work in the YourJS console:

Final Comments

As you can see using this function is very easy. Feel free to copy the code into your codebase. As always, happy coding! 😎


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK