Home » excel » MATLAB's xlsread gives different data than shown by Excel – hidden sheets

MATLAB's xlsread gives different data than shown by Excel – hidden sheets

Posted by: admin May 14, 2020 Leave a comment


I want to use xlsread in MATLAB R2017b to read from an externally supplied data file. Usually, this works fine for me. However, in this case I get data I can’t find in the .xls file and I don’t know what happened.

Here is screenshot of the .xls:
enter image description here

and here of the corresponding raw from xlsread:
enter image description here

Note that there is data in MATLAB (e.g. ‘Report tem…’) that cannot be found in Excel, that the columns are in a different order and that their headers also differ.

The data file is from Svenska Kraftnät, the Swedish Transmission System Operator and contains the generation and consumption of electrical energy for a certain year. You can find it here.

I use the following line to import the data in question (I am only interested in the numerical data and the timestamps, but used the raw to try to understand what is going on here):

[num,~,raw] = xlsread('n_fot2013-01-12.xls');

I am sorry if this a bad format for the question or if this is a dupe, but I didn’t have a clue how to make this question more general. Please feel free to suggest improvements!

How to&Answers:

Your workbook has a hidden sheet in it, and it is that sheet that is being read.

To read the visible sheet, specify the sheet name:

[num,~,raw] = xlsread('n_fot2013-01-12.xls','Förb + prod i Sverige');

To view the the hidden sheet, on the Home tab, in the Cells group, click Format > Visibility > Hide & Unhide > Unhide Sheet. Then select the hidden sheet.

There isn’t a way to tell xlsread to only read visible sheets, and by default it reads the first sheet (hidden or not).