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

조회 수: 5 (최근 30일)
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!

채택된 답변

Gareth
Gareth 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 CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by