Exporting uneven nested cells to excel

5 views (last 30 days)
aaammm
aaammm on 3 Mar 2023
Commented: aaammm on 10 Mar 2023
I have a 1x50 nested cell array where each cell has 3 columns but different number of rows that I need to export to excel.
I already have a loop to obtain the nested cell variable so I am using xlswrite('mydata.xlsx',data,'Sheet1') in the loop.
How can I move columns so the data is not overwritten in columns A:C for every iteration?
  1 Comment
Voss
Voss on 5 Mar 2023
You can set the Range of cells to be written to (xlswrite(filename,A,sheet,xlRange)), which you would adjust on each iteration of the loop.
However, it's likely easier to write the entire file once, without a loop at all.
Can you save your cell array in a .mat file and upload it here (using the paperclip button), and also share any code you have written so far for this?

Sign in to comment.

Answers (1)

Swaraj
Swaraj on 6 Mar 2023
Xlswrite is not recommended. Go through the below documentation.
You can go for “writecell” function. We can use it to specify range within which[JK1] we want to write data.
To avoid overwriting data in columns A:C for every iteration, you can use the Range input argument of the “writecell” function to specify the starting cell for each iteration
For example :
writecell(C,'C.xls','Sheet',2,'Range','A3:C5')
Go through the below documentation for further details.
  1 Comment
aaammm
aaammm on 10 Mar 2023
I've already tried writecell and it doesn't work if the cells have different sizes. The longest column is also 105k rows

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!