I have no idea what you are doing.
filename = 'solar_spectrum.xlsx';
[D,S,R] = xlsread(filename);
Phw = D(:,1);
hw = D(:,2);
E_g = hw >= 0.5;
S = trapz(hw(E_g), Phw(E_g))
patch([hw(E_g) fliplr(hw(E_g))], [Phw(E_g) fliplr(Phw(E_g))], 'y')
The plot shows the approximate area covered by the integration.
Experiment to get the result you want.