Results 1 to 7 of 7

Thread: Matlab + Excel File in Linux

  1. #1
    Join Date
    Jul 2006
    Beans
    809
    Distro
    Ubuntu 10.04 Lucid Lynx

    Matlab + Excel File in Linux

    In windows it is pretty easy to import data from Excel Files using Matlab. However, when I try to import data from an Excel File using Matlab in Linux I get the following error:
    Code:
    Warning: XLSREAD has limited import functionality on non-Windows platforms
    or in basic mode.  Refer to HELP XLSREAD for more information.
    > In xlsread at 198
      In beeplot at 4
    Warning: XLSREAD has limited import functionality on non-Windows platforms
    or in basic mode.  Refer to HELP XLSREAD for more information.
    > In xlsread at 198
      In beeplot at 6
    ??? Error using ==> xlsread at 211
    In basic mode, sheet argument must be a string.
    
    Error in ==> beeplot at 6
    [data2, header2] = xlsread(file.name, 2);
    I haven't a clue why this is not working. The file has been converted to xls instead of xlsx.

  2. #2
    Join Date
    Sep 2007
    Beans
    207

    Re: Matlab + Excel File in Linux

    When invoked in Windows, xlsread relies on Excel running as a COM server. If xlsread cannot access the COM server, it runs in basic mode. Are you able to access the spreadsheet in Windows in basic mode? The limitations of basic mode are listed here.

    Also, in basic mode if you specify a sheet name, it has to be a quoted string that is also case-sensitive. From the help:
    num = xlsread(filename, sheet, range, 'basic') imports data from the spreadsheet in basic import mode. xlsread uses this mode on systems where Excel software is not installed. Import ability is limited. xlsread ignores the value for range and, consequently, imports the whole active range of a sheet. (You can set range to the empty string ('').) Also, in basic mode, sheet is case sensitive and must be a quoted string.
    For your code, you might want to try
    Code:
    [data2, header2] = xlsread(file.name, 'Sheet2', '', 'basic')
    You can double-check by running that in Windows and see whether you can still get at the data.

  3. #3
    Join Date
    Mar 2009
    Beans
    3

    Re: Matlab + Excel File in Linux

    Matlab is working in both Windows and Ubuntu in the same way to me. I am able to extract data easily.

  4. #4
    Join Date
    Sep 2007
    Beans
    207

    Re: Matlab + Excel File in Linux

    The other thing you can try, and I saw this somewhere in a Matlab help topic, is that you can save your Excel file in Win95 format. Apparently you have to go back that far to ensure there aren't any screwy formatting things that have been added over the years, which are the things that aren't handled well in basic mode.

  5. #5
    Join Date
    Jul 2006
    Beans
    809
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Matlab + Excel File in Linux

    Okay, I figured out the problem. I was using a number instead of the sheet name. In windows this works just fine, but in linux it requires a sheet name. Everything is working now. Thanks for your help.

  6. #6
    Join Date
    May 2008
    Beans
    30

    Re: Matlab + Excel File in Linux

    Quote Originally Posted by lvleph View Post
    Okay, I figured out the problem. I was using a number instead of the sheet name. In windows this works just fine, but in linux it requires a sheet name. Everything is working now. Thanks for your help.
    So you mean, for sheet name, we shall use 'texts' and avoid use 'number'? In this way, we can directly import 2003/2007 excel files with lots of rows?

  7. #7
    Join Date
    Jul 2006
    Beans
    809
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Matlab + Excel File in Linux

    That is how I did it. But I still ended up having trouble with getting all the rows. I ended up just converting each sheet to a csv. It was much easier that way.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •