xlsfinfo
Provides information relevant to spreadsheets in file. This command is only available on Windows at this time.
Syntax
type = xlsfinfo(file)
type = xlsfinfo(file, 'interface', interfacetype)
[type, sheets] = xlsfinfo(file,...)
[type, sheets, format] = xlsfinfo(file,...)
[type, sheets, format, namedranges] = xlsfinfo(file,...)
Inputs
- file
- Name of the file to to check for Microsoft Excel compatibility.
- interfacetype
- Interface type that is used for xlsfinfo. Valid values are oml(default) and com. com interface runs the Qt/ActiveX COM libraries, which require Microsoft Excel to be installed on the machine. Named ranges in the spreadsheet can be detected only in the com interface.
Outputs
- type
- If the file is readable in Microsoft Excel, type is 'Microsoft Excel Spreadsheet'. If not readable, an empty string is returned. If no output or no other outputs are specified, information about an Excel compatible file, file, is shown in the OML command window.
- sheets (optional)
- Returns a cell array of nX2, where n is the number of sheets in file. The first column of sheets contains the name of the sheet. The second column of sheets contains the used data range from left to right. If this output is not specified, this information is printed in the OML command window.
- format (optional)
- Output that returns the type of the Excel compatible file. If it is not compatible, an empty string is returned.
- namedRanges (optional)
- Returns information about named ranges, if any. namedRanges is a cell array with three columns. The first column contains the name of range. The second column contains the parent sheet name where the named range is applicable. If applicable to the entire workbook, this field contains the filename, file. The third column contains the range of this named range entry.
Examples
Get information about an Excel file with sheet names printed to the OML
command window:
xlsfinfo('test.xls')
1: Sheet1 (Used range ~ B1:D3)
2: Sheet2 (Used range ~ A1:C4)
ans = Microsoft Excel Spreadsheet
Get information about an Excel file with the file format:
[filetype, sheets, format] = xlsfinfo('large2.xlsx')
filetype = Microsoft Excel Spreadsheet
sheets =
{
[1,1] Sheet1 name
[1,2] A1:A1
[2,1] Sheet2 new name
[2,2] A1:B3
[3,1] 3rd Sheet name
[3,2] A1:D32
[4,1] Info
[4,2] A1:D4
[5,1] sheet5_name
[5,2] A1:C1
}
format = xlOpenXMLWorkbook
Get information about a file that is not readable in Microsoft Excel:
xlsfinfo('Untitled1.oml')
1:Untitled1.oml (UsedRange ~ A1:A2)
ans =
Get information about a Microsoft Excel spreadsheet with named ranges through 'com' interface:
[type, sheets, fmt, range] = xlsfinfo('large1.xlsx', 'interface', 'com')
type = Microsoft Excel Spreadsheet
sheets =
{
[1,1] ABC123
[1,2] B2:AZ8448
}
fmt = xlOpenXMLWorkbook
ranges =
{
[1,1] namedrange1
[1,2] ABC123
[1,3] E10
[2,1] test
[2,2] large1.xlsx
[2,3] B7:E14
}