using excel template to save results in
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello again. I want to load data from an existing excel file 'T' with a specific formatting, use some values of the existing sheet to run in a matlab code and then save the excel file again but with the calculated values added to the sheet in an additional row.
I had an idea to use a template. So i tried to save the excel sheet in a matlab matrix 'mIN' with xlsread, change the matrix the way i want to 'mOut', make the existing excel file an empty template with copyfile(filename_template,filename) and then write the changed matrix into the empty template with writetable(mOut, filename). But this didnt work the way i want.
Hope you'll understand the problem. The question is if anyone has a strategy of how the problem can be solved.
0 Kommentare
Akzeptierte Antwort
Harsh
am 23 Jul. 2018
Without a concrete example of your intended goal, its a little hard to give an exact answer. However, going off of your description, the following maybe of help to you:
Additionally, a possible solution with readtable and writetable, would be as follows:
>> T = table(['M';'F';'M'],[45; 41; 40],...
{'NY';'CA';'MA'},[true;false;false]);
T =
3×4 table
Var1 Var2 Var3 Var4
____ ____ ____ _____
M 45 'NY' true
F 41 'CA' false
M 40 'MA' false
>> writetable(T,'myData.xls');
>> % Do stuff in MATLAB and create a table to write to a specific range in a sheet (append)
>> x = table('M',50,'AZ',true);
>> writetable(x,'myData.xls','Range','A5:D5','WriteVariableNames',false);
>> readtable('myData.xls')
ans =
4×4 table
Var1 Var2 Var3 Var4
____ ____ ____ _____
'M' 45 'NY' true
'F' 41 'CA' false
'M' 40 'MA' false
'M' 50 'AZ' true
If you want more control on readtable format for the variables, you can consider using detectImportOptions along with setvaropts and readtable.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!