Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

# Printing a cell array with differently sized column vectors into specific range of excel with a single call of xlswrite?

조회 수: 1(최근 30일)
nitoaxra 2018년 3월 14일
마감: MATLAB Answer Bot 2021년 8월 20일
My code is the following:
column='B';
sheet='testing';
for i=1:length(dimensions) %dimensions is the number of column vectors that are contained in the cell array
[nEle,~]=size(All_MPF{1,i}); %nEle is the length of the column vector for each iteration through the cell array
rnge= strcat(sprintf('%c2:%c',column,column),num2str(nEle+1)); %putting the excel range as a string
xlswrite('Dimensions.xlsx',All_MPF{1,i},sheet,rnge); % calling xlswrite for each column vector
column=column+1;
end
There are two things I'd like to do. First I would like to write the entire cell array into a specific starting position but with variable ending positions on the sheet. In principle it's vector 1 into B2:B15, vector 2 into C2:C9 etc.. The loop accomplishes this in its current state, but it's very slow. With just 7 short vectors it takes 6 seconds and I think the multiple calls on xlswrite could be the culprit here. For the real application of the program it could potentially be a lot more column vectors that are going into the excel sheet. So the question is if it's possible to write the entire cell array into the sheet with one call, starting the writing from row 2 in the sheet and ending at different rows for each vector, for example cell_array{1,1} at B2:B15,cell_array{1,2} at C2:C9, cell_array{1,3} at D2:D27 etc.

### 답변(1개)

Vishwanath Bailore Acharya 2018년 4월 16일

You can refer to the following link which speaks about exactly the same problem as in here. https://www.mathworks.com/matlabcentral/answers/119476-how-to-export-a-cell-array-into-excel-with-elements-of-different-sizes

### Community Treasure Hunt

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

Start Hunting!

Translated by