xlsfinfo

Reports whether a file is a readable spreadsheet and lists its sheets.

Category: Data Import and Analysis > Data Import and Export

Syntax

[type, sheets] = xlsfinfo(filename)

Returns a description of the file type and the sheet names.

Description

xlsfinfo is a quick inspection step before xlsread or readmatrix: it tells you which sheets exist so you can pick one by name. A new workbook written by xlswrite without a sheet name has a single sheet called Sheet1.

Newer code usually calls sheetnames or readtable directly, but xlsfinfo is still common in older scripts.

Input arguments

filename
Spreadsheet file name, such as 'data.xlsx'.

Output arguments

type
Text describing the format, for example 'Microsoft Excel Spreadsheet'; empty if the file is not a spreadsheet.
sheets
Cell array with the sheet names, in workbook order.

Example

Inspect a workbook

xlswrite('info_demo.xlsx', [1 2; 3 4], 'Data');
[type, sheets] = xlsfinfo('info_demo.xlsx')
Output
type = 'Microsoft Excel Spreadsheet'
sheets = 1×1 cell

    {'Data'}

Notes

When the file does not exist, MatLivre raises an error instead of returning an empty type.

See also

xlsread xlswrite sheetnames readtable