One way i could think of implementing the same is
1)Create a wrapper class for your tables
2)Perform all calculations at the backend and use that to diaplay the data
public class wrappercalc {
public class mainwrap {
public List < intwrap > Data {
get;
set;
}
}
public class intwrap {
public integer row1 {
get;
set;
}
public integer row2 {
get;
set;
}
public integer sum {
get;
set;
}
public intwrap(integer i1, integer i2) {
row1 = i1;
row2 = i2;
sum = i1 + i2; //Logic in constructor
}
}
public List < intwrap > getData() {
mainwrap m = new mainwrap();
m.Data = new List < intwrap > ();
intwrap i1 = new intwrap(25, 30);
intwrap i2 = new intwrap(50, 100);
m.Data.add(i1);
m.Data.add(i2);
return m.Data;
}
}
<apex:page controller="wrappercalc">
<apex:pageBlock >
<apex:pageBlockTable value="{!Data}" var="d">
<apex:column value="{!d.row1}" title="R1"/>
<apex:column value="{!d.row2}" title="R2"/>
<apex:column value="{!d.sum}" title="SUM"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
The above code should give an idea. The basic wrapper class concept is needed for your example.