How to insert a row and shift cells down in excel

9 ビュー (過去 30 日間)
Utkucan Genç
Utkucan Genç 2021 年 6 月 1 日
編集済み: Utkucan Genç 2021 年 6 月 1 日
Hello, I am currently working on a GUI that collects data from the user and delivers as an Excel file which has a pre-defined template. However, some sections of Excel template that the GUI inserts data have limited number of rows (let's say 20). If I want to insert data which need 30 rows, how can I insert it by shifting the following cells down and without disturbing the pre-defined template? I am using MATLAB 2020a and I can manipulate an Excel file via actxserver().
Edit: Can I insert rows with data? In another saying, can I write a ten rowed table on a single row such that the extra rows are inserted automatically? Now, I am pushing following cells downwards and writing data on the inserted cells.
Thanks in advance.

回答 (1 件)

Jakob B. Nielsen
Jakob B. Nielsen 2021 年 6 月 1 日
I believe you can achieve this using
Excel.Run('InsertRow');
you might have to have the relevant row selected before it works - I use it just to add new rows from the very top in an excel database, but that works like a charm at least :)
  1 件のコメント
Utkucan Genç
Utkucan Genç 2021 年 6 月 1 日
First of all, thank you for the commend.
I cannot use the line given above, I got 'Cannot run the macro 'InsertRow'.' error. However, I think I found the following solution for my problem: https://www.mathworks.com/matlabcentral/answers/157851-how-to-insert-new-column-to-existing-excel-sheet
Much appreciated.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by