This is a static copy of a profile report

Home

AcceptsSheetNameOrNumber>AcceptsSheetNameOrNumber.AcceptsSheetNameOrNumber (Calls: 2, Time: 0.000 s)
Generated 04-Jun-2021 04:11:20 using performance time.
class method in file C:\Program Files\MATLAB\R2020b\toolbox\matlab\io\spreadsheet\+matlab\+io\+internal\+functions\AcceptsSheetNameOrNumber.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
...t;SpreadsheetInputs.SpreadsheetInputsclass method2
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
1
classdef AcceptsSheetNameOrNum...
20.000 s0.7%
All other lines  0.000 s99.3%
Totals  0.000 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function82
Non-code lines (comments, blank lines)41
Code lines (lines that can run)41
Code lines that did run1
Code lines that did not run40
Coverage (did run/can run)2.44 %
Function listing
time 
Calls 
 line
< 0.001 
      2 
   1
classdef AcceptsSheetNameOrNumber < matlab.io.internal.FunctionInterface 
   2 
    %
   3 
    
   4 
    %   Copyright 2018-2019 The MathWorks, Inc.
   5 

   6 
    properties (Parameter)
   7 
        %SHEET the sheet from which to read
   8 
        %   Sheet can be a character vector containing the name of a sheet, or a
   9 
        %   positive scalar integer value, or an empty character array.
  10 
        %
  11 
        %   If specified as a name, the used sheet will match the name, regardless
  12 
        %   of sheet order. The sheet must appear in any file being read.
  13 
        %
  14 
        %   If specified as an integer, then the sheet in that position will be
  15 
        %   read, regardless of the sheet name.
  16 
        %
  17 
        %   If empty, no sheet is specified and the importing function will read
  18 
        %   from the appropriate sheet(s).
  19 
        %
  20 
        %   See also matlab.io.spreadsheet.SpreadsheetImportOptions
  21 
        Sheet = '';
  22 
    end
  23 

  24 
    methods
  25 
        function func = set.Sheet(func,rhs)
  26 
            [sh,func] = func.setSheet(rhs);
  27 
            func.Sheet = convertStringsToChars(sh);
  28 
        end
  29 

  30 
        function val = get.Sheet(func)
  31 
            containsOpts = any(strcmp(fieldnames(func),"Options"));
  32 
            try
  33 
                if containsOpts && any(strcmp(fieldnames(func.Options),"Sheet")) ...
  34 
                        && strcmp(func.Sheet,'')
  35 
                    % if the Options object is well-formed and Sheet has
  36 
                    % been initialized properly
  37 
                    val = func.Options.Sheet;
  38 
                else
  39 
                    % if the Sheet was supplied via NV pairs
  40 
                    val = func.Sheet;
  41 
                end
  42 
            catch
  43 
                % If the Options object is not well-formed
  44 
                val = func.Sheet;
  45 
            end
  46 
        end
  47 

  48 
        function [S, func] = executeImplCatch(func)
  49 
            ext = extractAfter(func.Extension,'.');
  50 
            if isempty(ext)
  51 
                ext = matlab.io.spreadsheet.internal.getExtension(func.Filename);
  52 
            end
  53 
            if isempty(func.Sheet)
  54 
                defaultSheet = 1;
  55 
            else
  56 
                defaultSheet = func.Sheet;
  57 
            end
  58 
            book = matlab.io.spreadsheet.internal.createWorkbook(ext, ...
  59 
                func.Filename, func.UseExcel, defaultSheet);
  60 
            % .ods and .xlsb files are interactive. Therefore, they require
  61 
            % the use of an Excel COM server to be read properly.
  62 
            if(book.Interactive)
  63 
                func.UseExcel = true;
  64 
            end
  65 
            if isempty(defaultSheet) || numel(book.SheetNames) == 1
  66 
                sheet = book.getSheet(1);
  67 
                if (ischar(defaultSheet) || isstring(defaultSheet)) && ...
  68 
                        ~isempty(defaultSheet) && ~strcmp(sheet.Name, defaultSheet)
  69 
                    error(message("MATLAB:spreadsheet:book:openSheetName",defaultSheet));
  70 
                end
  71 
            else
  72 
                sheet = book.getSheet(defaultSheet);
  73 
            end
  74 
            S = struct("Book",book, "Sheet", sheet);
  75 
        end
  76 
    end
  77 

  78 
    methods (Access='protected', Abstract)
  79 
        [val,func] = setSheet(func,val);
  80 
    end
  81 
end
  82