Importing text from Excel sheets

3 次查看(过去 30 天)
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 个)

产品

Community Treasure Hunt

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

Start Hunting!

Translated by