Excel Reading and Processing

1 visualizzazione (ultimi 30 giorni)
Unnikrishnan PC
Unnikrishnan PC il 2 Set 2011
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.

Risposte (1)

Fangjun Jiang
Fangjun Jiang il 2 Set 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 Commenti
Unnikrishnan PC
Unnikrishnan PC il 3 Set 2011
Thanks for your suggestion. As I understand xlsread and xlswrite read the whole data on a sheet as a vector and then after manipulation write it to another sheet.
In my problem, I need to read marks one by one manipulate it and then writing too depends on contents on the destination cell.(For example the StudentGrade.xls already contains grades of previous exams and the program should write only if the current grade is more than the earlier else discard)
Hope you can help me complete this project.
Thanks
U.K.
Fangjun Jiang
Fangjun Jiang il 3 Set 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.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by