Clear Filters
Clear Filters

how can i Insert row in between the existing data in an excel sheet without overwriting the below data.

7 views (last 30 days)
xlRange4 = ['B',num2str(nextRow2)];
xlRange5 = ['E',num2str(nextRow2)];
xlswrite('IgnTimgTar_ac_Compliance.xlsx',data,'Result',xlRange4);
xlswrite('IgnTimgTar_ac_Compliance.xlsx',data,'Result',xlRange5);,
i am using this code but there the below data is getting overwrittened.

Answers (1)

Walter Roberson
Walter Roberson on 19 Aug 2021
You will need to use activexserver() to connect to Excel, and use the DCOM interface to execute Insert commands
There is no facility inside MATLAB itself for inserting or deleting rows or columns in spreadsheets (without rewriting the rest of the spreadsheet)
  4 Comments
Walter Roberson
Walter Roberson on 19 Aug 2021
If you are talking about MATLAB cell arrays, then the answer is more No than Yes.
MATLAB cell arrays are arrays of pointers to descriptions of data ,with the description most often including a pointer to the storage for the values.
When you assign to an element of a cell array, the pointer to the description of the entry is overwritten with a pointer to the description of the new value. The memory itself is not copied, just the pointer.
In order to insert a new row in a cell array, matlab has to first create a new larger cell array. It then copies the pointers to descriptions from the old cell to the new cell, in the appropriate places. The data enclosed is not moved, just the pointers. But the process does have to create the new cell array (and after dispose of the old list of pointers).
At the moment I cannot think of anything in MATLAB that is known to be implemented as a linked list (there might be internal ones not visible to users)

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!