www.gusucode.com > datastoreio工具箱 matlab源码程序 > datastoreio/spreadsheetDatastore.m
function ds = spreadsheetDatastore(location, varargin) %SPREADSHEETDATASTORE Datastore for a collection of spreadsheet files. % SSDS = spreadsheetDatastore(LOCATION) creates a SpreadsheetDatastore % based on a spreadsheet file or a collection of such files in LOCATION. % LOCATION has the following properties: % - Can be a filename or a folder name % - Can be a cell array of multiple file or folder names % - Can contain a relative path % - Can contain a wildcard (*) character % - All of the files in LOCATION must have the extension .xlsx, .xls, % .xlsm, .xltm, or .xltx % % SSDS = spreadsheetDatastore(__,'IncludeSubfolders',TF) specifies the % logical true or false to indicate whether the files in each folder and % its subfolders are included recursively or not. % % SSDS = spreadsheetDatastore(__,'FileExtensions',EXTENSIONS) specifies % the extensions of files to be included in the SpreadsheetDatastore. The % extensions are not required to be either .xlsx, .xls, .xlsm, .xltm, or % .xltx. Values for EXTENSIONS can be: % - A character vector, such as '.xls' or '.xlsm' or '.myformat' (empty % quotes '' are allowed for files without extensions) % - A cell array of character vector, such as {'.xls', '.xlsm', '.myformat'} % % SSDS = spreadsheetDatastore(__,'TextType', TEXTTYPE) specifies the % output data type of text variables, with TEXTTYPE specified as either % 'char' or 'string'. If the output table from the read, readall or % preview functions contains text variables, then TEXTTYPE specifies the % data type of those variables. If TEXTTYPE is 'char', then the output is % a cell array of character vectors. If TEXTTYPE is 'string', then the % output has type string. % % SSDS = spreadsheetDatastore(__,'Name1',Value1,'Name2',Value2,...) specifies the % properties of SSDS using optional name-value pairs. % % SpreadsheetDatastore Methods: % % preview - Read 8 rows from the start of the datastore. % read - Read subset of data from the datastore. % readall - Read all of the data from the datastore. % hasdata - Returns true if there is more data in the datastore. % reset - Reset the datastore to the start of the data. % partition - Return a new datastore that represents a single % partitioned part of the original datastore. % numpartitions - Return an estimate for a reasonable number of % partitions to use with the partition function for % the given information. % sheetnames - returns sheetnames from a file or a file index. % % SpreadsheetDatastore Properties: % % Files - Files included in datastore. % Sheets - Sheets of interest % Range - Range of interest % NumHeaderLines - Number of header lines to skip from the % beginning of the block specified by Range. % ReadVariableNames - Indicator for reading first row of the block % specified by Range as variable names. % VariableNames - Names of variables. % VariableTypes - Output types of the variables. % SelectedVariableNames - Variables of interest. % SelectedVariableTypes - Output types for the variables of interest. % ReadSize - Upper limit on the size of the data returned by the read method. % % Example: % -------- % % Create a SpreadsheetDatastore % ssds = spreadsheetDatastore('airlinesmall_subset.xlsx') % % We are only interested in the Arrival Delay data % ssds.SelectedVariableNames = 'ArrDelay' % % Preview the first 8 rows of the data as a table % tab8 = preview(ssds) % % Sum the Arrival Delays % sumAD = 0; % ssds.ReadSize = 'sheet'; % while hasdata(ssds) % tab = read(ssds); % data = tab.ArrDelay(~isnan(tab.ArrDelay)); % filter data % sumAD = sumAD + sum(data); % end % sumAD % % See also datastore, mapreduce, readtable, xlsread, matlab.io.datastore.SpreadsheetDatastore. % Copyright 2015-2016 The MathWorks, Inc. ds = matlab.io.datastore.SpreadsheetDatastore(location, varargin{:}); end