Write to existing excel file

1 view (last 30 days)
Eric
Eric on 9 Sep 2012
I want to write a variable (vardata which is 101x120 matrix) to a preexisting excel file (Group 1). I've tried ActiveX but this doesn't seem to do what I want. Ultimately, I want each subject through my loop to have her vardata variable appended to the preexisting excel file. I think I am making this harder than it needs to be but I cannot get vardata to be written to the excel file without it overwriting the previous subject's data. Any help would be appreciated.
Eric

Answers (1)

Image Analyst
Image Analyst on 9 Sep 2012
Define "append". xlswrite will add cells to an existing workbook. If the cells are written to a location where there are no existing cells, then the existing cells will remain intact. If you write to cells in a range that overlaps existing cells, the cells in the overlap region will get replaced and the non-overlapping ones will remain.
If you want to find out the cell range that is used by your workbook, you need to use ActiveX and ask for Excel.worksheets.Item(sheetIndex).UsedRange or Excel.ActiveSheet.UsedRange.

Community Treasure Hunt

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

Start Hunting!