Getting an array of column names at SheetJS
<p>I'm trying to parse an Excel spreadsheet (.xlsx) into JSON.</p>

<p>I'm using the <a href="https://github.com/SheetJS/js-xlsx" rel="noreferrer">SheetJS</a> node package for it.</p>

<p>However I can't realize such a simple thing as - how do I get a column name in the same format as it is stored internally?</p>

<p>Below is my code:</p>

<pre><code>function _buildColumnsArray(range) {
    // range = "A1:CA38"
    // ...
    // should return ['A', ..., 'Z', 'AA', ..., 'AZ', 'BA', ..., 'BZ', 'CA'...]
}

// --------

var workbook = XLSX.readFile(fileUrl),
    sheets = workbook.Sheets,
    result = {};

result.sheetNames = [];

for (var i = 0; i &lt; workbook.SheetNames.length; i++) {
    var sheet = workbook.Sheets[workbook.SheetNames[i]],
        csvSheet = XLSX.utils.sheet_to_csv(sheet);

    // '!ref' referring to a specific range by docs
    if (sheet["!ref"]) {
        var columns = _buildColumnsArray(sheet["!ref"]),
            rows = _buildRowsArray(columns, csvSheet);

        // build final result
        result[workbook.SheetNames[i]] = {
            columns: columns,
            rows: rows
        };
        result.sheetNames.push(workbook.SheetNames[i]);
    }
}
</code></pre>

<p>Here is what I'm currently trying which is not perfectly working: <a href="https://jsfiddle.net/t8hej9hu/" rel="noreferrer">https://jsfiddle.net/t8hej9hu/</a></p>