sheetnames
从数据存储中查询工作表名称
说明
示例
查询工作表名称
创建包含文件 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'
查询数据存储中第一个(且仅此一个)文件的工作表名称。
sheetnames(ssds,1)
ans = 13×1 string array "1996" "1997" "1998" "1999" "2000" "2001" "2002" "2003" "2004" "2005" "2006" "2007" "2008"
输入参数
ssds
— 输入数据存储
SpreadsheetDatastore
对象
输入数据存储,指定为 SpreadsheetDatastore
对象。使用 spreadsheetDatastore
函数或 datastore
函数根据您的数据创建数据存储对象。
filename
— 数据存储中的文件
字符向量 | 字符串标量
数据存储中的文件,指定为字符向量或字符串标量,其中包含要查询的文件的名称。
filename
的值必须与数据存储的 Files
属性包含的文件名完全匹配。要确保文件名完全匹配,请使用 ssds.Files{N}
指定 filename
,其中 N
是 Files
属性中的文件的索引。
示例: names = sheetnames(ssds,ssds.Files{1})
返回数据存储 ssds
的 Files
属性指定的第一个文件中包含的工作表名称。
数据类型: char
| string
I
— 文件索引
正整数
文件索引,指定为正整数。I
不能超出 ssds
中的文件数。
数据类型: double
输出参量
names
— 工作表名称
字符串数组
工作表名称,以字符串数组形式返回,其中包含指定文件中的工作表名称。
数据类型: string
版本历史记录
在 R2016a 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 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)