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

조회 수: 2 (최근 30일)
Aymeric Ferreira
Aymeric Ferreira 2019년 12월 30일
편집: Aymeric Ferreira 2019년 12월 30일
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
Image Analyst
Image Analyst 2019년 12월 30일
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 2019년 12월 30일
편집: Aymeric Ferreira 2019년 12월 30일
Thank you for your answer, you can find attached an example of Data_struct.mat

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by