Documentation

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.

xlsfinfo

Determine if file contains Microsoft Excel spreadsheet

Syntax

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

Description

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.

example

[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 character vector, ''.

Examples

collapse all

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 =

xlOpenXMLWorkbook

status contains descriptive text which indicates that the xlsread function can read the sample file.

Input Arguments

collapse all

Name of file, specified as a character vector.

Example: 'myFile.xlsx'

Data Types: char

Output Arguments

collapse all

Type of file, returned as a character vector.

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

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

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

Worksheet names, returned as a 1-by-n cell array of character vectors, 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.

File format description returned by Excel, returned as a character vector.

On Windows systems with Excel software, xlFormat is 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 character vector, ''.

Limitations

  • xlsfinfo supports only 7-bit ASCII characters.

More About

collapse all

Tips

  • 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?