How to copy and paste a single row in an excel file to another excel file?

10 ビュー (過去 30 日間)
Lelia Rosenkrans
Lelia Rosenkrans 2018 年 12 月 3 日
編集済み: Lelia Rosenkrans 2018 年 12 月 4 日
Hello,
I am trying to copy a single row from multiple excel files and paste them into a master document. These files are all in one folder, but do not have similar file names. The row I am looking to copy contains both numbers and letters, and is row 3 of the original excel sheet.
Here is an example of how the excel file is formated
A B C D E F ...
1 L L L L L L
2 R R R R R R
3 13 Q 14 T S 75
4 0 0 0 0 0 0
Any help is much appreciated!

採用された回答

GT
GT 2018 年 12 月 3 日
I am using R2018b, and there are a couple of ways of solving this. I like the following:
ds = spreadsheetDatastore(pwd,'Range','A3:D3','ReadVariableNames',false)
ds.readall
Please note that:
  • Range is where we specify the range that you are looking for in Excel (same way you would declare this in Excel)
  • Given that I don't know the VariableNames I put false, but you could extend this
  • I used pwd as the path but you could run this from anywhere:)
I hope this helps:)
There are other types of Datastores which make these kind of things really simple. I believe SpreadsheetDataStore came out in R2016a.

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by