xlswrite - Errors all the time
10 views (last 30 days)
Show older comments
Hello,
using xlswrite, and within changing anythig, i have this both error:
% Error using xlswrite (line 220) Invoke Error, Dispatch Exception: Source: Microsoft Excel Description: Microsoft Excel ne peut accéder au fichier « N:\CELINE_B\MIO\13_TRANSMED\DATA\DATA_SEA_KEEPER\FINAL_DATA_2005\MD_2005_02_air_sea.xlsx ». Plusieurs raisons sont possibles :
• Le nom du fichier ou le chemin d'accès n’existe pas. • Ce fichier est actuellement utilisé par un autre programme. • Le classeur que vous essayez d’enregistrer porte le même nom qu’un classeur actuellement ouvert. Help File: xlmain11.chm Help Context ID: 0 %
and
% Error using xlswrite (line 220) The file N:\CELINE_B\MIO\13_TRANSMED\DATA\DATA_SEA_KEEPER\FINAL_DATA_2005\MD_2005_02.xlsx is not writable. It may be locked by another process. %
this is my code for example:
mois_2 = find(data_output_1(:,3)==2); data_mois_2 = data_output_1(mois_2,:);
if exist('data_mois_2','var')==1 xlswrite([path_data_output,racine,'_02','.xlsx'],labels_1); xlswrite([path_data_output,racine,'_02','.xlsx'],data_mois_2,1,'A2'); end
mois_2_all_col = find(data_output_2(:,3)==2); data_mois_2_all_col = data_output_2(mois_2_all_col,:);
if exist('data_mois_2_all_col','var')==1 xlswrite([path_data_output,racine,'_02_air_sea','.xlsx'],labels_2); xlswrite([path_data_output,racine,'_02_air_sea','.xlsx'],data_mois_2_all_col,1,'A2'); end
And i already use the find process runnig to close Excel exe. Maybe my script is dummy. Any idea to stop definitively this kind of errors?
thanks in advance
Regards Céline
Answers (1)
David Sanchez
on 13 May 2014
Try closing your excel document before trying to write on it.
That kind of errors occur when you try to write in a document that is already open.
And make sure that the location where you are trying to write your file is available for writing.
Use fulfile function to build full file name from directories.
help fulfile
doc fulfile
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!