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 Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by