Determine whether file contains a Microsoft Excel spreadsheet
typ = xlsfinfo(filename)
[typ, desc] = xlsfinfo(filename)
[typ, desc, fmt] = xlsfinfo(filename)
xlsfinfo filename
typ = xlsfinfo(filename) returns the string 'Microsoft Excel Spreadsheet' if the file specified by filename is an Excel file that can be read by the MATLAB xlsread function. Otherwise, typ is the empty string, (''). The filename input is a string enclosed in single quotation marks.
[typ, desc] = xlsfinfo(filename) returns in desc a cell array of strings containing the names of each spreadsheet in the file. If a spreadsheet is unreadable, the cell in desc that represents that spreadsheet contains an error message.
[typ, desc, fmt] = xlsfinfo(filename) returns in the fmt output a string containing the Excel-reported file format. On UNIX systems, or on Windows systems without Excel software installed, xlsfinfo returns fmt as an empty string, ('').
xlsfinfo filename is the command format for xlsfinfo. It returns only the first output, typ, assigning it to the MATLAB default variable ans.
If your system has Excel for Windows installed, xlsfinfo uses the COM server to obtain information. This server is part of the typical installation of Excel for Windows. If the COM server is unavailable, xlsfinfo returns a warning indicating that it cannot start an ActiveX server. To establish connectivity with the COM server, you might need to reinstall your Excel software.
Get information about an .xls file:
[typ, desc, fmt] = xlsfinfo('myaccount.xls')
typ =
    Microsoft Excel Spreadsheet
desc =
    'Sheet1'    'Income'    'Expenses'
fmt =
Export the .xls file to comma-separated value (CSV) format. Use xlsfinfo to see the format of the exported file:
[typ, desc, fmt] = xlsfinfo('myaccount.csv');
fmt =
Export the .xls file to HTML format. xlsfinfo returns the following format string:
[typ, desc, fmt] = xlsfinfo('myaccount.html');
fmt =
Export the .xls file to XML format. xlsfinfo returns the following format string:
[typ, desc, fmt] = xlsfinfo('myaccount.xml');
fmt =

标签: none