How to: write .xls into a dynamic folder name ?

4 visualizaciones (últimos 30 días)
John Doe
John Doe el 2 de Dic. de 2020
Comentada: John Doe el 2 de Dic. de 2020
Hello everyone,
It may be a silly question for you all folks, but i'm kick in a teeth on that one...
First the code and then what i want to do.
Prompt={'Nom', 'Surname', 'Birth_date (mm dd aaaa)','Evaluation_date (mm dd aaaa)'};
Dlgtitle=' patient data';
Def={'Duarte','Mickaels','01 01 2000','16 02 2018'};
Answer=inputdlg(Prompt,Dlgtitle,1,Def);
Patient_info={Answer{1},Answer{2},Answer{3}};
Eval_date={'Evaluation',Answer{4}};
Muscle={'Fl_Pr','Ex_Su','Bic','Tri'};
Task=[1;2;3;4;5;6];
Task1={'Task'};
mkdir ([Answer{1},' ',Answer{2},' ',num2str(Answer{3})]) % create folder with data from the prompt Patient_info
xlswrite(???????????????.xls,Task,'Fpic','A5'));
xlswrite((???????????????..xls,Patient_info,'Fpic','A2'));
xlswrite((???????????????.,Eval_date,'Fpic','A3'));
xlswrite((???????????????.,Muscle,'Fpic','B4'));
xlswrite((???????????????.,Task1,'Fpic','A4'));
I'm trying to write an .xls into the folder i just created for each of my patients from the data i put in the prompt.
If someone can help...
Thanks you all !

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Dic. de 2020
Editada: Walter Roberson el 2 de Dic. de 2020
folder = [Answer{1},' ',Answer{2},' ',num2str(Answer{3})];
if ~exist(folder, 'dir'); mkdir(folder); end
filename = 'patient_data.xlsx';
fullname = fullfile(folder, filename);
xlwrite(fullname, Task, 'Fpic', 'A5');
xlswrite(fullname, Patient_info, 'Fpic', 'A2');
and so on.
Are you sure you want spaces in the folder name? That is legal, but it does tend to make programming more difficult. For example,
system(['dir ', fullname])
would fail because of the spaces in the file name, and you would need
system(['dir "', fullname, '"'])
  1 comentario
John Doe
John Doe el 2 de Dic. de 2020
Thanks Walter, mixed with the answer of Jegan, it works flawlessly ! You're life saver !
About the folder name it's not an obligation, i have let the space because it's a small programm but i see your point :) thanks for the extra info ;)

Iniciar sesión para comentar.

Más respuestas (1)

Ananthi Jegan
Ananthi Jegan el 2 de Dic. de 2020
Hi John
You can create the excel files dynamically from the inputs received in Prompt as follows:
xlswrite(fullfile(XLFilePath,XLFilename),Array,Sheet,Range) where XLFilename should be the name of file including the extension '.xlsx' or '.xls'
An example to use from above lines of code:
xlswrite(fullfile(XLFilePath,XLFilename),Muscle,'Fpic','B4')
I hope this answers your query.
  1 comentario
John Doe
John Doe el 2 de Dic. de 2020
Thanks Jegan, mixed with the answer of Walter, it works flawlessly ! You're life saver too :) !

Iniciar sesión para comentar.

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by