%

% Copyright 2018 The MathWorks, Inc.
function readMetadataHelper(this, idx)
    sheetName = this.getSheetFromIdx(idx);
    usedRange = this.getUsedDataRange(sheetName);
    if strlength(usedRange) == 0
        return;
    end

    sRange = this.Ranges(idx);
    sRange = xls.internal.Range.fixIfPointRange(sRange, usedRange);
    opts = this.getImportOptions(sheetName, sRange, usedRange);

    T = readtable(this.Filename, ...
        opts, ...
        'ReadVariableNames', false, ...
        'UseExcel', this.UseExcel);

    if isempty(T)
        headers = [];
        metadata = [];
        startRow = -1;
    else
        strData = T.Variables;
        headers = strData(1, :);
        metadata = strData(2:end, :);
        options = ["ignorecase", "tokens", "once"];
        rx = "^([a-z]+)(\d+):[a-z]+\d+$";
        value = regexp(opts.DataRange, rx, options{:});
        startRow = str2double(value(2));
    end

    this.rangeID = xls.internal.readMetadata(this.Filename, sheetName, ...
        sRange, headers, metadata, startRow);

    this.M = T(1:this.getRange.DataStartRow-1, :);
end
