This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Determine if file contains Microsoft Excel spreadsheet


  • status = xlsfinfo(filename)
  • [status,sheets] = xlsfinfo(filename)
  • [status,sheets,xlFormat] = xlsfinfo(filename)


status = xlsfinfo(filename) indicates if filename is a file that the xlsread function can read.

[status,sheets] = xlsfinfo(filename) additionally returns the name of each spreadsheet in the file.


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


collapse all

View Information About Spreadsheet File

Create a sample Excel file named myExample.xlsx.

values = {1, 2, 3 ; 4, 5, 'x' ; 7, 8, 9};
headers = {'First', 'Second', 'Third'};
xlswrite('myExample.xlsx', [headers; values]);

Call xlsfinfo to get information about the file.

[status,sheets,xlFormat] = xlsfinfo('myExample.xlsx')
status =

Microsoft Excel Spreadsheet

sheets = 

    'Sheet1'    'Sheet2'    'Sheet3'

xlFormat =


status is a descriptive string indicating that the xlsread function can read the sample file.

Input Arguments

collapse all

filename — Name of filestring

Name of file, specified as a string.

Example: 'myFile.xlsx'

Data Types: char

Output Arguments

collapse all

status — Type of filestring

Type of file, returned as a string.

  • If filename is a file that xlsread can read, then status is a descriptive string, such as 'Microsoft Excel Spreadsheet'.

  • If filename is not a file that xlsread can read, then status is an empty string, ''.

  • If MATLAB® cannot find the file, then xlsfinfo returns an error.

sheets — Worksheet names1-by-n cell array of strings

Worksheet names, returned as a 1-by-n cell array of strings, where n is the number of worksheets in the file. Each cell contains the name of a worksheet. If xlsread cannot read a particular worksheet, the corresponding cell contains an error message.

If xlsfinfo cannot read the file, then sheets contains an error message.

xlFormat — File format description returned by Excelstring

File format description returned by Excel, returned as a string.

On Windows systems with Excel software, xlFormat is a nonempty string, such as one of the following.

'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, xlFormat is an empty string, ''.


  • xlsfinfo supports only 7-bit ASCII characters.

More About

collapse all


  • If xlsfinfo warns that it cannot start an ActiveX® server, then the COM server, which is part of the typical Excel installation, is unavailable. In this case, consider reinstalling your Excel software. On systems with Excel for Windows, xlsfinfo uses the COM server to obtain information.

See Also


Introduced before R2006a

Was this topic helpful?