function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chanagan SakulteeraChanagan Sakulteera 

How to set this table by apex

Hi all,
I want to set this is table in vf page by apex code. How to set ?? 

User-added image

this is vf page me.
<apex:page standardController="Product_Service__c" extensions="CostCalculation2Extention" >

<apex:sectionHeader Title="Cost Calculation" subtitle="{!theProduct.Name}"/>
<apex:form >
    
    <apex:pageBlock title="Cost Calculator">
        <table border="1">
            <tr>
                <th>No. of Pax</th>
                <th colspan="2" align="center">A</th>
                <th>B</th>
                <th colspan="4" align="center">C1</th>
                <th colspan="4" align="center">C2</th>
                <th colspan="4" align="center">C3</th>
                <th colspan="4" align="center">C4</th>
                <th colspan="4" align="center">C5</th>
                <th colspan="4" align="center">C5</th>
                <th colspan="2" align="center">E</th>
                <th colspan="3" align="center">G</th>
            </tr>
            <tr>
                <td><apex:commandButton value="Add Row"/></td>
                <td>International Flight</td>
                <td>Domestic Flight</td>
                <td></td>
                <td>C1.1</td>
                <td>C1.2</td>
                <td>C1.3</td>
                <td>C1.4</td>
                <td>C2.1</td>
                <td>C2.2</td>
                <td>C2.3</td>
                <td>C2.4</td>
                <td>C3.1</td>
                <td>C3.2</td>
                <td>C3.3</td>
                <td>C3.4</td>
                <td>C4.1</td>
                <td>C4.2</td>
                <td>C4.3</td>
                <td>C4.4</td>
                <td>C5.1</td>
                <td>C5.2</td>
                <td>C5.3</td>
                <td>C5.4</td>
                <td>C6.1</td>
                <td>C6.2</td>
                <td>C6.3</td>
                <td>C6.4</td>
                <td>E1.1</td>
                <td>E2.2</td>
                <td>Sales</td>
                <td>Operation</td>
                <td>Others</td>
            </tr>
        </table>
    
    </apex:pageBlock>

</apex:form>
</apex:page>

Thank you.
Chanagan SakulteeraChanagan Sakulteera
Here is a table that I want.
User-added image
SFDC coderSFDC coder
hi ,

try this sample code
 
<apex:page controller="demo_EXTN">
<apex:form >
<apex:pageBlock >
 <apex:variable value="{!0}" var="j"/>
<apex:pageBlockTable id="row" value="{!matrix}" var="i">
    
    <apex:column headerValue="Quarter/Year">
        <apex:variable value="{!j+1}" var="j"/>
         <apex:repeat value="{!j}" var="q">
        <apex:outputText >Quarter YR{!q}</apex:outputText>
        </apex:repeat>              
    </apex:column>
    
    <apex:column headerValue="Actual Year 1">
    <apex:inputText />
    </apex:column>
    
    <apex:column headerValue="Actual Year 2">
    <apex:inputText />
    </apex:column>
    
    <apex:column headerValue="Actual Year 3">
    <apex:inputText />
    </apex:column>
    
    <apex:column headerValue="Actual Year 4">
    <apex:inputText />
    </apex:column>
    
       <!--apex:column >
        <apex:repeat id="columns" value="{!matrix}" var="k" >
          <td>{!k}</td>
        </apex:repeat>    
    </apex:column-->
    
 </apex:pageBlockTable>   
</apex:pageBlock>
</apex:form>
</apex:page>
 
public class demo_EXTN{ 
 public List<List<String>> matrix{get;set;}
 public demo_EXTN()
 {
 matrix = new List<List<String>>();
 List<Contact> contactList = [SELECT id, firstname FROM contact limit 4];
 system.debug(contactList); 
 List<Account> accountList = [select id, name FROM Account limit 4];
 system.debug(accountList);
 List<String> row = new List<String>(); // You know that the top left String will be empty 
 row.add('Acc/Contact'); // setup list of contact labels at top of grid/matrix 
 for(Integer i = 0; i<contactList.size(); i++)
 { 
 System.debug(contactList[i].firstname);    
 row.add(contactList[i].firstname);
 } // add the first row to the grid 
 matrix.add(row); 
 System.debug(matrix); // Setup list of account labels in rows of grid 
 for(Integer j=0; j<accountList.size(); j++)
 { 
 row = new List<String>();
 System.debug(accountList[j].name); 
 row.add(accountList[j].name); 
 matrix.add(row);   
 } 
 system.debug(matrix);
 } 
 }

is this what you want?