필터 지우기
필터 지우기

Importing text from Excel sheets

조회 수: 1 (최근 30일)
Shawn
Shawn 2013년 3월 21일
I've been working on a script to take an excel workbook, and import text from each sheet. The cell I am importing from in each sheet is the same, so I decided to use a loop; however, the loop's output variable only contains the first designated cell from the last designated sheet and nothing more.
for i=1:3
[ndata,text,alldata]=xlsread('Book1.xls',i,'B7:B7,B15:B15,B22:B22');
end
The 'text' variable, which I am trying to get containing all the cells I need, will end up being a 1x1 cell.
I have tried going through the loop and writing to a text while within the loop, but I am unaware on how to use a "fprintf" command for cell arrays.
In short, what I am trying to do is create a variable of some sort containing the text from multiple cells from multiple sheets, which I can then export to a text document. Any help with absolutely any of this would be incredibly appreciated.

채택된 답변

ChristianW
ChristianW 2013년 3월 21일
Here's an example on how to use fprintf with cells:
C{1} = sprintf('Hello\n');
c = {'A','B','C';1,2,3};
C{2} = sprintf('%s\t%d\n',c{:});
s = char(C)
fprintf('%s',C{:})

추가 답변 (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