Is there a way to specify currency for template?

Posted by: supply on 23 May 2023, 11:26 pm EST

    • Post Options:
    • Link

    Posted 23 May 2023, 11:26 pm EST

    Hi, is there a way to specify currency code for currency field format via template?

    For instance, could I use some global setting during rendering to specify that? For my use cases I would like to use one template to render documents, but the data could contain different currency fields of the one currency code. Or is there another way to get what I need?

    Thanks in advice.

  • Posted 24 May 2023, 8:48 pm EST

    Hello Artem,

    As of now, there is no direct functionality to apply formatting via the template feature.

    But you can apply the format to the Excel template cell and it will get applied to all the data associated with that field.

    Please see the following demo sample demonstrating the same and let us know if you have any different understanding:

    https://www.grapecity.com/documents-api-excel/demos/templateworkwithchart

    Regards,

    Prabhat Sharma.

  • Posted 24 May 2023, 10:29 pm EST - Updated 24 May 2023, 10:34 pm EST

    Hi Prabhat,

    Thank you for advice, but if I get you right I will prepare the template for some currency. However, I need to specify the currency symbol according to the data fields providing by a data source. In my case the currency fields are specified by the value and ISO currency code. And I need to provide output accordingly. Is there an option?

  • Posted 25 May 2023, 10:55 pm EST

    Hello Artem,

    If we understand your use case, then you want to apply the different formats to each data row which can not be achieved using the template as you can apply a single format for one data field when using the template.

    If you want to apply different formats to data rows then you need to apply the format after processing the template.

    Please share your expected output so that we can prepare a stripped-down sample accordingly to assist you further.

    Regards,

    Prabhat Sharma.

  • Posted 28 May 2023, 2:44 pm EST

    Hi Prabhat,

    Let me explain. For my needs I would like to parametrize the document template via a concurrency code to format prices according to sale regions. So I prefer to have a single template that I use to render the documents with different currencies, however the currency is unique per document. Is it possible?

  • Posted 28 May 2023, 8:06 pm EST

    Hello Artem,

    As per your use case you want to set different currency formats as per different regions.

    When creating a template it is not possible to make it generalize as per the current region.

    As a workaround, you can set the number format property of that template cell before processing the template as per the current region.

    RegionInfo region = RegionInfo.CurrentRegion;

    String currencySymbol = region.CurrencySymbol;

    workbook.ActiveShet.Range[“templateCellAddress”].NumberFormat = “custom format”;

    workbook.ProcessTemplate();

    Regards,

    Prabhat Sharma.

  • Posted 28 May 2023, 8:06 pm EST

    Hello Artem,

    As per your use case you want to set different currency formats as per different regions.

    When creating a template it is not possible to make it generalize as per the current region.

    As a workaround, you can set the number format property of that template cell before processing the template as per the current region.

    RegionInfo region = RegionInfo.CurrentRegion;

    String currencySymbol = region.CurrencySymbol;

    workbook.ActiveShet.Range[“templateCellAddress”].NumberFormat = “custom format”;

    workbook.ProcessTemplate();

    Regards,

    Prabhat Sharma.

  • Posted 29 May 2023, 1:39 pm EST

    Hi,

    I got you, thanks. I thought there could be a better solution avoiding a cell lookup with currency format.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels