Importing text from Excel sheets
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
0 Kommentare
Akzeptierte Antwort
ChristianW
am 21 Mär. 2013
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!