Excel Reading and Processing
3 views (last 30 days)
Show older comments
I need to read marks one by one from one excel sheet (for eg: Marks for Maths & Chem arranged column wise for 100 students)calculate their grade (For eg: If Marks Above 50 Grade A else Grade B)and write it to another sheet in the corresponding cells. Can someone help me out this using actxserver.Thanks in advance.
0 Comments
Answers (1)
Fangjun Jiang
on 2 Sep 2011
Do you have to use actxserver? If not, why not use xlsread?
[Num,Txt,Raw]=xslread('StudentMark.xls')
For example, if
Num=[90 40;70 80;30 60;60 20;20 80]
Grade=repmat({'B'},size(Num))
Grade(Num>50)={'A'}
xlswrite('StudentGrade.xls',Grade)
2 Comments
Fangjun Jiang
on 3 Sep 2011
You can use more input arguments of the xlsread and xlswrite function. xlsread(File, Sheet, Range) xlswrite(File,Data,Sheet, Range). However, I believe it's more efficient for you to read in all the data once, process it and then write it back. If the sheet is huge and you don't have enough RAM to hold all the data at once, you might want to considering reading/writing multiple times. xlsread() and xlswrite() have lots of overhead. It will be slow if you want to do read and write for each student.
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!