How to add column header using xlswrite1?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
Respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!