sheetnames
Query sheet names from datastore
Description
Examples
Query Sheet Names
Create a datastore containing the file airlinesmall_subset.xlsx
.
ssds = spreadsheetDatastore('airlinesmall_subset.xlsx')
ssds = SpreadsheetDatastore with properties: Files: { ' ...\matlab\toolbox\matlab\demos\airlinesmall_subset.xlsx' } AlternateFileSystemRoots: {} Sheets: '' Range: '' ReadFailureRule: 'error' MaxFailures: Inf Sheet Format Properties: NumHeaderLines: 0 ReadVariableNames: true VariableNames: {'Year', 'Month', 'DayofMonth' ... and 26 more} VariableTypes: {'double', 'double', 'double' ... and 26 more} Properties that control the table returned by preview, read, readall: SelectedVariableNames: {'Year', 'Month', 'DayofMonth' ... and 26 more} SelectedVariableTypes: {'double', 'double', 'double' ... and 26 more} ReadSize: 'file'
Query the sheet names of the first (and only) file in the datastore.
sheetnames(ssds,1)
ans = 13×1 string array "1996" "1997" "1998" "1999" "2000" "2001" "2002" "2003" "2004" "2005" "2006" "2007" "2008"
Input Arguments
ssds
— Input datastore
SpreadsheetDatastore
object
Input datastore, specified as a SpreadsheetDatastore
object. Use the spreadsheetDatastore
function
or the datastore
function to
create a datastore object from your data.
filename
— File in datastore
character vector | string scalar
File in datastore, specified as a character vector or string scalar containing the name of the file to query.
The value of filename
must match exactly the file name
contained in the Files
property of the datastore. To
ensure that the file names match exactly, specify
filename
using ssds.Files{N}
where
N
is the index of the file in the
Files
property.
Example: names = sheetnames(ssds,ssds.Files{1})
returns
sheet names contained in the first file specified in the
Files
property of the datastore
ssds
.
Data Types: char
| string
I
— File index
positive integer
File index, specified as a positive integer. I
cannot
exceed the number of files in ssds
.
Data Types: double
Output Arguments
names
— Sheet names
string array
Sheet names, returned as a string array containing the sheet names in the specified file.
Data Types: string
Version History
Introduced in R2016a
See Also
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)