How to add column header using xlswrite1?

조회 수: 2 (최근 30일)
Ganesh K Davanagege
Ganesh K Davanagege 2016년 11월 26일
편집: Walter Roberson 2016년 11월 27일
I have the problem with this code. I have used xlswrite1 to write into Excel file. I want to add column and row header to the data. I have the problem in xlswrite1 which gives the error as
Error using xlswrite1 (line 142)
Error: Object returned error code: 0x800A03EC
Error in xlswrite1 (line 142)
error('MATLAB:xlswrite:SelectDataRange',lasterr);
%%Multiple variable with label - Writing into excel file - Active X
clc
tic
Excel = actxserver ('Excel.Application');
File='testdata.xlsx';
if ~exist(File,'file')
ExcelWorkbook = Excel.workbooks.Add;
ExcelWorkbook.SaveAs(File,1);
ExcelWorkbook.Close(false);
end
timeVariable=20*rand(1,10)
timeVariable = timeVariable'
tempVariable = 10*rand(1,10)
tempVariable = tempVariable'
a={'Time','Temperature'}
b= [timeVariable tempVariable]
c.col = a
c.val = b
sheet = 1;
xlswrite1(filename,c.col,sheet,'A1')
xlswrite1(filename,c.val,sheet,'A2')
invoke(Excel.ActiveWorkbook,'Save');
Excel.Quit
Excel.delete
clear Excel
toc

답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by