xlswrite overwriting the same excel sheet
2 views (last 30 days)
Show older comments
I am having an issue where the xlswrite function is constantly overwriting the same sheet after each iteration. The code used to work and I'm unsure whether the upgrade in Excel is causing the issue. I have tried the xlswrite1() function but I get the an evalin error (not sure what it means!). data1 is a string array for the headers and data2 has all the values I wish to export to an excel file.
for i=1:size(data2,3) %
xlswrite(output_file,data1(1,:),i,'A1') %excel headers
xlswrite(output_file,data2(:,:,i),i,'A2') %excel data
end
I have noticed that data2 is also overwriting data1 even though they should be printing along different rows in excel. Any help or insight would be greatly appreciated. Thanks, Seb
1 Comment
Jan
on 1 Aug 2017
Edited: Jan
on 1 Aug 2017
If you provide some input data, we could cross check the behavior. If you post the code you use to run xlswrite1 and the error message, the readers could suggest a fixing. You mention an "upgrade in Excel", but do not explain the details. Currently posting an asnwer requires too much guessing.
This works fine in R2016b/Excel 2010/Win7/64
xlswrite('asd.xlsx', {'a', 'b', 'c'}, 1, 'A1')
xlswrite('asd.xlsx', {1, 2, 3; 4, 5, 6}, 1, 'A2')
xlswrite('asd.xlsx', {'a', 'b', 'c'}, 2, 'A1')
xlswrite('asd.xlsx', {7, 8, 9; 10, 11, 12}, 2, 'A2')
Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!