Struct with multiple rows to excel file with one sheet per row

2 Ansichten (letzte 30 Tage)
Aymeric Ferreira
Aymeric Ferreira am 30 Dez. 2019
Bearbeitet: Aymeric Ferreira am 30 Dez. 2019
Hello,
I'm working with structure and I would like to save the data into one excel file.
My structure is composed on 77 rows, each row is a 2D table that I output as a single Excel sheet in an Excel workbook.
I'm looping over each row for the moment but the problem is the code is quite slow, and the more rows I have, the longer is my saving.
My saving code is the following :
for i = 1:77
Data = struct2table(Data_struct(i));
writetable(Data,filename,'sheet',i);
end
It works well but I would like to speed it up. It took minimum 3 seconds to save one sheet and obviously it increases when the file grow up. Is there a way to save it without a loop ? Or save only one time ?
For a file of 4MB and 77 sheets it takes more than 5 minutes
Thank you
  2 Kommentare
Image Analyst
Image Analyst am 30 Dez. 2019
Attach Data_struct in a .mat file so we can try some things. Make it easy for us to help you, not hard!
save('answers.mat', 'Data_struct');
then attach answers.mat with the paper clip icon.
Aymeric Ferreira
Aymeric Ferreira am 30 Dez. 2019
Bearbeitet: Aymeric Ferreira am 30 Dez. 2019
Thank you for your answer, you can find attached an example of Data_struct.mat

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by