Search code examples
pdfreporting-servicesformatreportcurrency

Currency disappears when exported as PDF


When I export my report to pdf, the currency disappears.

enter image description here

Here is the code:

                                <TextRun>
                                  <Value>=Fields!dTransactionAmount.Value</Value>
                                  <Style>
                                    <FontFamily>Tahoma</FontFamily>
                                    <FontSize>9pt</FontSize>
                                    <Format>=Code.getChargeCurrency()</Format>
                                  </Style>
                                </TextRun>
                              </TextRuns> 

Public Shared Function getChargeCurrency() As string
    if NOT chargeNum = invoiceNumber then
        currency ="'$'#,0.00;('$'#,0.00)"
    else 
        currency="#,0.00;(#,0.00)"
        
    end if
    
    chargeNum = invoiceNumber
    Return currency
    End Function ``` 

Solution

  • No really an answer but mu guess....

    If you render directly to PDF via a url does it work then? Test it using a url something like

    http://myReportServer/ReportServer?/myReportName&rs:Format=PDF  
    

    If this works then I suspect the variable is getting set when you render to screen so when you render to PDF chargenum is already = invoicenumber.

    I don't know enough about your situation to know what the best solution is but you could try to store the Globals.RenderFormat value ina variable and check that this has not changed when you check to see if the other two variable have changed.

    Something like...

    if chargeNum <> invoiceNumber AND lastRenderFormat <> currentRenderFormat then
        currency ="'$'#,0.00;('$'#,0.00)"
    else 
        currency="#,0.00;(#,0.00)"
        
    end if
    
    chargeNum = invoiceNumber
    lastRenderFormat = currentRenderFormat