How does XLSWRITE interact with EXCEL?
조회 수: 1 (최근 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
채택된 답변
Walter Roberson
2016년 5월 17일
If you want the full interaction, see http://www.mathworks.com/matlabcentral/fileexchange/10465-xlswrite1
댓글 수: 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!