How do I delete an entire row from Excel from MATLAB?
123 views (last 30 days)
Ultimately I want to delete an entire row from an excel file (say, row 10) and shift the rows 11 onwards up so that there isn't an empty space in the file.
I can envisage a long winded solution to this using xlswrite to overwrite all the previous rows, but is there a simple solution to this? I can't find a way of doing it anywhere.
Guillaume on 10 Jul 2017
It's not hard to do in matlab if you know excel VBA. If you don't, it's just as easy to record a macro in excel and use that rather than trying to do it in matlab.
The following should work (untested since I don't have matlab installed on this machine):
file = 'C:\somewhere\somefile.xlsx';
sheet = 'Sheet1'; %can be name or numeric index
row = 10;
excel = actxserver('Excel.Application');
workbook = excel.Workbooks.Open(file);
worksheet = workbook.Worksheets.Item(sheet);