Writing cell arrays to excel when each element contains a table
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello,
I need to extract a range of data with different data types for each column. I need to do this for roughly 3000 sheets.
I need to find a good way to store my data as I loop through the sheets, so I tried populating an element of a cell array with the exported range with each iteration. The problem is I don't know how I can write that data to excel.
The range will always have the same number of columns and the number of rows is variable.
Thanks!
Stephanie
댓글 수: 0
답변 (1개)
Kaitlyn Keil
2018년 8월 7일
Hi Stephanie,
I think what you are wanting is either writetable or xlswrite, as described in the page Write Data to Excel Sheets. It looks like xlswrite can directly take your cell array and filename, and even write each piece to a new sheet if that's what you'd like to do.
Hope that helps!
댓글 수: 6
Kaitlyn Keil
2018년 8월 7일
Is there a reason that table2cell wouldn't work for the initial conversion? If so, then this is how I might do it (roughly):
cur_row = 1;
for i = 1:num_sheets
tab = <however you access your table data>;
temp_storage = table2cell(tab);
upper_corner = ['A' num2str(cur_row)];
status = xlswrite(filename, temp_storage, sheet, upper_corner);
cur_row = cur_row + length(temp_storage);
end
sheet would just be constant.
This doesn't prevent you from counting rows, but I'm not sure why you are trying to avoid that in this case. Sorry if this isn't what you were hoping for!
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!