How does XLSWRITE interact with EXCEL?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Brad
am 17 Mai 2016
Beantwortet: Walter Roberson
am 17 Mai 2016
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 17 Mai 2016
If you want the full interaction, see http://www.mathworks.com/matlabcentral/fileexchange/10465-xlswrite1
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!