xlswrite error - worksheet could not be activated

52 visualizaciones (últimos 30 días)
vasja sivec
vasja sivec el 25 de Mzo. de 2016
Respondida: giovanacgois el 17 de Mayo de 2018
Dear Matlab users,
Last week my Matlab started to return an error when trying to export data into excell. For example:
------------- command and error message:
>> xlswrite('myfile',data)
Error using xlswrite (line 219)
Excel Worksheet could not be activated.
------------- error object:
The exception object (from line 219) reads:
-
identifier : 'MATLAB:xlsread:WorksheetNotActivated'
message: 'Excel Worksheet could not be activated.'
cause: 0x0 cell (authors tesxt: an empty cell)
--------------
I can export to other types of files (csv, txt,...)
I am having a hard time understanding what the problem is. I am using my office computer. It might be related to our security policy. Our IT department could not help me.
Anyone had any similar experience and found a solution?
Thank you for your help and kind regards,
Vasja
  4 comentarios
K E
K E el 8 de Jul. de 2016
Editada: K E el 29 de Sept. de 2016
Presently getting this error on one machine but not another for the same Excel file! And when I quit the Matlab with the error and restart it, I no longer get the error.
Here is the output Walter requested on my particular file, though I am not the original question author:
[status,sheets] = xlsfinfo(filename)
status =
Microsoft Excel Spreadsheet
sheets =
'SheetName1' 'SheetName2'
And here is how I am calling the command when the error is returned,
CsvFile = 'L:\Directory1\Spreadsheet1.xlsx';
[junk,fieldNamesA1,junk2] = xlsread(CsvFile,'SheetName2');
Any help greatly appreciated, since this is preventing running a necessary daily report.
Shashwat Jain
Shashwat Jain el 1 de Jul. de 2017
try to use "xls" format instead of "xlsx". For example.... "filename.xls" worked for my case but "filename.xlsx" didnt work.

Iniciar sesión para comentar.

Respuestas (4)

giovanacgois
giovanacgois el 17 de Mayo de 2018
I tried to re-run Matlab with Admin privileges, it worked for me.

Toritris
Toritris el 10 de En. de 2017
Same problem, but over a loop in which the Excel sheet was repeatedly called, it worked the first time, then broke! Opened Excel and there was the 'allow other programs to ...' button, so I clicked it, but it still didn't work. Finally, closed and opened Matlab and it was ok.

Faiz Gouri
Faiz Gouri el 25 de Jul. de 2017
I faced the similar issue with MATLAB R2017a, restarting MATLAB and closing all xls files fixed the problem for me

vasja sivec
vasja sivec el 22 de Ag. de 2017
Just an update...
In my case the culprit was my coding.
I had set up a loop that opened an i) excel file, ii) updated the excel file and iii) closed it. The problem (at least it seems so...) was that somehow the "updating command" (ii) executed before the "close file command" (iii) has properly finished all its tasks.
SOLUTION in my case: I paused the execution temporarily in order to give the "close file command" enough time to finish. I added the following line after the "close file command": . pause(0.5)
Speed was of no essence for my task.
Hope it helps, Vasja

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by