Skip to Main Content Skip to Search
Product Documentation

xlsfinfo - Determine whether file contains Microsoft Excel spreadsheet

Syntax

status = xlsfinfo(filename)
[status,sheets] = xlsfinfo(filename)
[status,sheets,format] = xlsfinfo(filename)

Description

status = xlsfinfo(filename) returns a nonempty string when the specified file is in an Excel format that xlsread can read (for example, 'Microsoft Excel Spreadsheet'). Otherwise, status is an empty string, ''.

[status,sheets] = xlsfinfo(filename) returns a cell array of strings containing the names of each spreadsheet in the file.

[status,sheets,format] = xlsfinfo(filename) returns a string containing the format description that Excel returns for the file. On systems without Excel for Windows, format is an empty string, ''.

Input Arguments

filename

String enclosed in single quotation marks that specifies the name of the file.

Output Arguments

status

If the file is in an Excel format that xlsread can read, status is a nonempty string. Otherwise, status is an empty string, ''.

sheets

If the file is in an Excel format that xlsread can read, sheets is a 1-by-n cell array of strings, where n is the number of worksheets. Each cell contains the name of a worksheet. If MATLAB cannot read a particular worksheet, the corresponding cell contains an error message.

If the file is not in a readable Excel format, sheets is a string containing an error message.

format

On Windows systems with Excel software, format is a string that contains the description that Excel returns for the file. For example:

'xlOpenXMLWorkbook'Spreadsheet in XLSX format (Excel 2007 or later).
'xlWorkbookNormal' or 'xlExcel8'Spreadsheet in XLS format (compatible with Excel 97-2003).
'xlCSV'File in comma-separated value (CSV) format.
'xlHtml' or 'xlWebArchive'Spreadsheet exported to HTML format.

On all other systems, format is an empty string, ''.

Examples

Consider a hypothetical file with worksheets named Sheet1, Income, and Expenses. Get information about the file:

[typ, desc, fmt] = xlsfinfo('myaccount.xlsx')

This code returns:

typ =
    Microsoft Excel Spreadsheet

desc = 
    'Sheet1'    'Income'    'Expenses'

fmt = 
    xlOpenXMLWorkbook

See Also

xlsread | xlswrite

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS