How does XLSWRITE interact with EXCEL?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Brad
il 17 Mag 2016
Risposto: Walter Roberson
il 17 Mag 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 Commenti
Risposta accettata
Walter Roberson
il 17 Mag 2016
If you want the full interaction, see http://www.mathworks.com/matlabcentral/fileexchange/10465-xlswrite1
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Spreadsheets in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!