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
SFDC_2706SFDC_2706 

Hide one of the worksheet when exported from a button click using Apex...!!

Hi Experts,

I need a help in SFDC development which is developed using xml platform and I have never worked on this language but this is being used in one of our previous functionality and now I need to amend the same for the client. Below is the description of my task :

- There is a button and when clicked it exports an workbook with many worksheets in it.
- Now I need to HIDE one worksheet on one of the condition. For example, XYZ worksheet should only get open when "Reason for change" field on object is blank otherwise it should get hidden. 

Attaching VF code written only for that particular sheet :

VF Page :-

<Worksheet ss:Name="Budget History">
<Table>
<Column ss:Width="160" ss:StyleId="s_plain"/>
<Column ss:Width="80" ss:StyleId="s_plain"/>
<Column ss:Width="160" ss:StyleId="s_plain"/>
<Column ss:Width="80" ss:StyleId="s_plain"/>
<Column ss:Width="80" ss:StyleId="s_plain"/>
<Column ss:Width="80" ss:StyleId="s_plain"/>

<Row>
<Cell ss:Index="2" ss:MergeAcross="3" ss:StyleID="Quote_For_Services"><Data ss:Type="String"><b>Quote for Services</b></Data></Cell>
</Row>
<Row>
<Cell ss:Index="1" ss:StyleID="Arial_Eleven_bold"><Data ss:Type="String"><b>{!proposal.Apttus_Proposal__Account__r.name}</b></Data></Cell>
</Row>
<Row></Row>
<Row> <Cell ss:Index="2" ss:MergeAcross="3" ss:StyleID="s4"><Data ss:Type="String"><b>Budget History</b></Data></Cell> </Row>
<Row>
<Cell ss:Index="2" ss:MergeAcross="3" ss:StyleID="s4"><Data ss:Type="String"><b>Protocol: {!proposal.APTS_Protocol_No__c}</b></Data></Cell>
</Row>
<Row></Row> <Row></Row>
<Row>
<Cell ss:StyleID="s2_budget_summary"><Data ss:Type="String"><b>Category</b></Data></Cell>
<Cell ss:StyleID="s2_budget_summary"><Data ss:Type="String"><b>Updated Study Value</b></Data></Cell>
<Cell ss:StyleID="s2_budget_summary"><Data ss:Type="String"><b>Previous Study Value*</b></Data></Cell>
<Cell ss:StyleID="s2_budget_summary"><Data ss:Type="String"><b>Difference</b></Data></Cell> </Row> <apex:repeat value="{!topTableDisplay}" var="line"> <Row> <Cell ss:Index="1" ss:StyleID="s1_left_right_border_history"><Data ss:Type="String">{!line.categoryName}</Data></Cell> <Cell ss:StyleID="{!currencyNameStyleIdMapHistory[totalsCurrency]}"><Data ss:Type="Number">{!line.currentValue}</Data></Cell>
<Cell ss:StyleID="{!currencyNameStyleIdMapHistory[totalsCurrency]}"><Data ss:Type="Number">{!line.previousValue}</Data></Cell>
<Cell ss:StyleID="{!currencyNameStyleIdMapHistory[totalsCurrency]}"><Data ss:Type="Number">{!line.difference}</Data></Cell>
</Row> </apex:repeat>
<Row></Row> <Row></Row>
<Row> <Cell ss:StyleID="s2_budget_summary"><Data ss:Type="String"><b>Proposal Number</b></Data></Cell>
<Cell ss:StyleID="s2_budget_summary"><Data ss:Type="String"><b>Proposal Version</b></Data></Cell>
<Cell ss:StyleID="s2_budget_summary"><Data ss:Type="String"><b>Date</b></Data></Cell>
<Cell ss:StyleID="s2_budget_summary"><Data ss:Type="String"><b>Reason</b></Data></Cell>
<Cell ss:StyleID="s2_budget_summary"><Data ss:Type="String"><b>Total Value</b></Data></Cell>
<Cell ss:StyleID="s2_budget_summary"><Data ss:Type="String"><b>Difference</b></Data></Cell> </Row>
<apex:repeat value="{!bottomTableDisplay}" var="line"> <Row> <Cell ss:Index="1" ss:StyleID="s1_left_right_border_history"><Data ss:Type="String">{!line.proposalNumber}</Data></Cell>

<Cell ss:StyleID="s1_left_right_border_history"><Data ss:Type="String">{!line.proposalVersion}</Data></Cell>
<Cell ss:StyleID="s1_left_right_border_history"><Data ss:Type="String">{!line.DatePresented}</Data></Cell>
<Cell ss:StyleID="s1_left_right_border_history"><Data ss:Type="String">{!line.reason}</Data></Cell>
<Cell ss:StyleID="{!currencyNameStyleIdMapHistory[totalsCurrency]}"><Data ss:Type="Number">{!line.TotalValue}</Data></Cell>
<Cell ss:StyleID="{!currencyNameStyleIdMapHistory[totalsCurrency]}"><Data ss:Type="Number">{!line.difference}</Data></Cell> </Row> </apex:repeat>
</Table>
</Worksheet>

I need to hide this worksheet when "Reason for change" is not blank and show this sheet when "Reason for change" is blank.

I tried many things to resolve it but couldn’t succeed. Now I need your help to get it done asap. Please let me know how can you help me and when can we connect for the same.