Autofill range in excel using Matlab
Mostrar comentarios más antiguos
Hi guys,
I have a formula in an excel cell. I am trying to open the excel file from matlab and autofill the column (equivalent to double clicking the bottom right hand corner of the cell in excel). I have tried to set up a com.excel.application but have run into some problems, "I get the error No appropriate method, property, or field constants for class COM.Excel_Application."
My code is
Excel = actxserver('Excel.Application');
ResultFile = [excelFilePath_2 excelFileName2 '.xlsx'];
Workbook = invoke(Excel.Workbooks,'Open', ResultFile);
resultsheet = 'strain';
try
sheet = get(Excel.Worksheets,'Item', resultsheet);
invoke(sheet, 'Activate');
catch
% If the Excel Sheet ‘ExperimentSheet’ is not found, throw an error message
errordlg([resultsheet 'not found']);
end
r(1) = Excel.ActiveSheet.Range('I2');
r(2) = Excel.ActiveSheet.Range('J2');
r(3) = Excel.ActiveSheet.Range(['J' int2str(size(time,1))]);
sourceRange = Excel.ActiveSheet.get('Range',r(1),r(2));
fillRange=Excel.ActiveSheet.get('Range',r(1),r(3));
sourceRange.AutoFill(fillRange,Excel.constants.xlFillDefault)
invoke(Excel.ActiveWorkbook,'Save');
Excel.Quit
Excel.delete
clear Excel
Is there any other method to do what I am trying to achieve? Thanks
4 comentarios
Guillaume
el 2 de Dic. de 2014
When reporting an error message thrown by matlab, always report the entire error message including the part that shows the line where the error occurs.
Which line is at fault?
Yasha
el 2 de Dic. de 2014
Yasha
el 4 de Dic. de 2014
Guillaume
el 4 de Dic. de 2014
Did you not spot the answer below?
Does it not answer your question?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Data Import from MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!