time | Calls | line |
---|
| | 1 | function d = columnNumber(s)
|
| | 2 | % COLUMNNUMBER(S) returns the column number of S which is a spreadsheeet
|
| | 3 | % column letter 'A'..'Z', 'AA','AB'...'AZ', and so on.
|
| | 4 | %
|
| | 5 | % Examples:
|
| | 6 | % base27dec('A') returns 1
|
| | 7 | % base27dec('Z') returns 26
|
| | 8 | % base27dec('IV') returns 256
|
| | 9 | %
|
| | 10 | % See also matlab.io.spreadsheet.internal.columnLetter
|
| | 11 |
|
| | 12 | % Copyright 2014-2018 The MathWorks, Inc.
|
| | 13 |
|
| 1 | 14 | try
|
< 0.001 | 1 | 15 | s = upper(s);
|
< 0.001 | 1 | 16 | if length(s) == 1
|
< 0.001 | 1 | 17 | d = s(1) -'A' + 1;
|
| | 18 | else
|
| | 19 | cumulative = sum(26.^(1:numel(s)-1));
|
| | 20 | indexes_fliped = 1 + s - 'A';
|
| | 21 | indexes = fliplr(indexes_fliped);
|
| | 22 | indexes_in_cells = mat2cell(indexes, 1, ones(1,numel(indexes))); %#ok<MMTC>
|
| | 23 | d = cumulative + sub2ind(repmat(26, 1,numel(s)), indexes_in_cells{:});
|
< 0.001 | 1 | 24 | end
|
| | 25 | catch
|
| | 26 | d = NaN;
|
| 1 | 27 | end
|
< 0.001 | 1 | 28 | end
|
Other subfunctions in this file are not included in this listing.