How to add column header using xlswrite1?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
Réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!