Function File: [filetype] = xlsfinfo (filename [, reqintf])
Function File: [filetype, sh_names] = xlsfinfo (filename [, reqintf])
Function File: [filetype, sh_names, fformat] = xlsfinfo (filename [, reqintf])
Function File: [filetype, sh_names, fformat, nmranges] = xlsfinfo (filename [, reqintf])
Function File: […] = xlsfinfo (…, verbose)

Query a spreadsheet file for some info about its contents.

Inputs:

  • filename is the name, or relative or absolute filename, of a spreadsheet file.

    If multiple spreadsheet I/O interfaces have been installed, reqintf can be specified to request a specific interface. If omitted xlsfinfo selects a suitable interface; see the help for xlsread for more information.

    If optional argument verbose (numerical or logical; always the last argument) is specified as logical ’true’ or numerical 1, xlsfinfo echoes info about the spreadsheet I/O interface it uses.

Outputs:

  • Return argument filetype returns a string containing a general description of the spreadsheet file type: "Microsoft Excel Spreadsheet" for Excel spreadsheets, "OpenOffice.org Calc spreadsheet" for .ods spreadsheets, "Gnumeric spreadsheet" for Gnumeric spreeadsheets, or "" (empty string) for other or unrecognized spreadsheet formats.

    If filename is a recognized Excel, OpenOffice.org Calc or Gnumeric spreadsheet file, optional return argument sh_names contains an Nx2 list (cell array) of sheet names contained in filename and total used data ranges for each sheet, in the order (from left to right) in which they occur in the sheet stack.

    Optional return value fformat currently returns "xlWorkbookNormal" for .xls formats, "xlOpenXMLWorkbook" for .xlsx, "xlCSV" for .csv, "GnumericWorkbook" for .gnumeric, "ODSWorkbook" for .ods, "StarOfficeWorkbook" for .sxc, or "" (empty) for other file formats.

    Optional return argument nmranges is a cell array containing all named data ranges in the file in the first column, the relevant sheet and the cell range in the second and third column and if appropriate the scope of the range in the fourth column. For named ranges defined for the entire workbook the fourth column entry is empty. Named ranges only work with the COM, POI, OXS and OCT interfaces, and with the UNO interface only properly for Excel files.

If no return arguments are specified the sheet names are echoed to the terminal screen plus for each sheet the actual occupied data range. The occupied cell range will have to be determined behind the scenes first; this can take some time for some of the Java based interfaces. Any Named ranges defined in the spreadsheet file will be listed on screen as well.

For OOXML spreadsheets no external SW is required but full POI and/or UNO and/or COM support (see xlsopen) may work better or faster; to use those specify "poi", "uno" or "com" for reqintf. For Excel ’95 files use "com" (windows only), "jxl", "oxs" or "uno". Gnumeric and ODS files can be explored with the built-in OCT interface (no need to specify reqintf then) although again the COM, JOD, OTK or UNO interfaces may work faster, depending on a.o., the size of the file. Note that the JXL, OXS, OTK and JOD interfaces don’t support Named ranges so when using these interfaces no information about Named ranges is returned.

Examples:

  exist = xlsfinfo ('test4.xls');
  (Just checks if file test4.xls is a readable Excel file)
  [exist, names] = xlsfinfo ('test4.ods');
  (Checks if file test4.ods is a readable LibreOffice Calc file and
   returns a list of sheet names and types)

See also: oct2xls, xlsread, xls2oct, xlswrite.

Package: io