If you want the full interaction, see http://www.mathworks.com/matlabcentral/fileexchange/10465-xlswrite1
How does XLSWRITE interact with EXCEL?
2 次查看(过去 30 天)
显示 更早的评论
I’m attempting to write data into an EXCEL spreadsheet using the following MATLAB code;
%
% XLSWRITE_Test.m
%
% Clear out all workspace variables and the command window
clear all;
close all;
clc;
% Pause and allow variables to be cleared out of the workspace
pause(1);
% Disable the warnings for adding specified worksheets. These occur because
% EXCEL has a default value of 3 worksheets / file
warning('off', 'MATLAB:xlswrite:AddSheet');
% Assign data
Company = {'Company_A' 'Company_B'};
Run_Numbers = {'10000' '2500'};
Make = {{'Ford'; 'Audi'; 'Chevy'} {'Chevy'; 'Volvo'}};
% Create column headers to A4, B4, and C4
xlswrite('(A)Untitled_Data.xls', {'Company'}, 1, 'A4');
xlswrite('(A)Untitled_Data.xls', {'Run_Number'}, 1, 'B4');
xlswrite('(A)Untitled_Data.xls', {'Make'}, 1, 'C4');
% Write company names, run numbers, and make starting at cell A5
xlswrite('(A)Untitled_Data.xls', Company', 1, 'A5');
xlswrite('(A)Untitled_Data.xls', Run_Numbers', 1, 'B5');
%xlswrite('(A)Untitled_Data.xls', Make(:,1)', 1, 'C5');
%xlswrite('(A)Untitled_Data.xls', Make(:), 1, 'C5');
xlswrite('(A)Untitled_Data.xls', Make{:,1}', 1, 'C5');
% For inspection, have Windows open the EXCEL workbook just created
winopen('(A)Untitled_Data.xls');
I expect to see this result:
Company Run_Number Make
Company_A 10000 Ford Audi Chevy
Company_B 2500 Chevy Volvo
But keep getting this one:
Company Run_Number Make
Company_A 10000 Ford Audi Chevy
Company_B 2500
I’ve tried changing the range from C5 to C5:C6, but get the same result.
I’m not sure if I don’t understand the interaction between XLSWRITE and EXCEL, or if I’ve missed something else completely. But when I substitute
Not sure if anyone has encountered this or not. But any ideas would be greatly appreciated.
Thank you.
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!