Importing text from Excel sheets

3 ビュー (過去 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 Center および File ExchangeSpreadsheets についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by