How to add column header using xlswrite1?
조회 수: 2 (최근 30일)
이전 댓글 표시
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 Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!