How does XLSWRITE interact with EXCEL?

1 回表示 (過去 30 日間)
Brad
Brad 2016 年 5 月 17 日
回答済み: Walter Roberson 2016 年 5 月 17 日
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.

採用された回答

Walter Roberson
Walter Roberson 2016 年 5 月 17 日

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by