Writing Excel Currency Data with Proper Currency Formatting

31 May 2021
KingswaySoft Team

Background

Microsoft Excel has many built-in number formats, and the default format is General, where values are displayed just the way that you type them in. However, this is not what we would always want when we perform an integration. Data would need to be formatted with respect to many aspects depending on what we are writing. In such cases, we can select the Custom category in the Number tab of the Formal Cells dialog box and fill in the specified format in Type to define a new format. But how would we handle this when we run an automated job? When we create new excel sheets dynamically, how would we make sure that it's always formatted as required by the business?

 In this blog post, we will be demonstrating how to use KingswaySoft Premium Excel Destination component to write the data with defined format (currency format) into Excel file. The components used in the below example are as follows:

The Swiss franc is the currency of Switzerland etc., and the official symbols Fr. and fr.  are widely used. In this business use case, we would be seeing how to format and write these input number values into Excel destination file as below using the SSIS package.

Demonstration Data

For our example, let us generate the sample data in the database and retrieve as input data using Premium ADO.Net Source component, as shown below. The Source data is as shown below.

Sample Data in Premium ADO NET Source

And in the table below, the “Expected Data in excel” is how it should be properly formatted with the separator and we expect to see this in the excel sheet.

Expected Data in Excel

It might appear very easy to achieve when you look at the above screenshot, but it is actually a pretty difficult task in an ETL process without a proper tool and some creative thinking. It is particularly a challenge when your operating system has a specific regional setting which is not necessarily the exact way how you would like to write the Excel file. This particular situation is one of the client cases that we have assisted with a client of ours recently, we thought it is interesting to share, which is the reason for this blog post. Let's see how we can properly address this requirement leveraging the power of the Premium Excel Destination component. Our goal is to achieve a consistent writing irregardless of the regional setting of the operating system.

Configure the Excel Thousands separator

Before we start to configure your SSIS data flow and related, we need to make sure that the Excelthe data is stored and displayed with proper “Thousands separator” (for this case, it is single quote '), we would need to configure the Excel sheet setting as shown below. Note that this is a one time configuration.

Open your Excel sheet and Navigate to File > Options > Advanced, uncheck the Use system separators check box. This will allow you to specify a custom one. And then, type new separators in the Thousands separator box.

Excel Thousands Separate Setting

Configure Excel Destination

After configuring the General page in the Premium Excel Destination component, the component will read the meta data from the specified Excel file automatically (click “Refresh Component” if there is metadata change for the Excel), and the default Data Type is “DT_WSTR”, which is character string as below.

Currency Field in Premium Excel Destination Component (as Text Field)

To write the sample numbers into Excel specified column, we map the input column “Number” into the respective field in Excel.  The customized Number format in the Excel as requested will be "Fr." #,###.00 (note: the thousand separator “,” will be replaced to single quote ' according to the Excel global thousand separator configuration). And we need to manipulate the data format in Excel Destination component accordingly so the value can be converted to required format. to achieve this, we can click “Data Type” and choose “DT_CY- Currency” from the drop down list and change the “Format String” to "Fr." #,###.00 in the field.

Currency Field in Premium Excel Destination Component

With above configuration, after executing the package successfully, these input values will be loaded into destination Excel Column “Number in Currency” and the format is as expected as below.

Final Result of Excel Currency Writing

Conclusion

You can efficiently write in different formats when working with Excel file using the Premium Excel Destination component, regardless of the data format of source data, there is no need to manually handle the data format in the Excel file post integration, thus making SSIS data integration much more streamlined. All KingswaySoft components used in the above example, both (Premium ADO.NET Source and the Premium Excel Destination) can be found in our SSIS Productivity Pack. The SSIS Productivity Pack is a collection of advanced SSIS components to enable greater developer productivity. Feel free to give it a try and see how our components can make your integration easier and efficient.

Archive

October 2024 1 September 2024 1 August 2024 2 July 2024 1 June 2024 1 May 2024 1 April 2024 2 March 2024 2 February 2024 2 January 2024 2 December 2023 1 November 2023 1 October 2023 2 August 2023 1 July 2023 2 June 2023 1 May 2023 2 April 2023 1 March 2023 1 February 2023 1 January 2023 2 December 2022 1 November 2022 2 October 2022 2 September 2022 2 August 2022 2 July 2022 3 June 2022 2 May 2022 2 April 2022 3 March 2022 2 February 2022 1 January 2022 2 December 2021 1 October 2021 1 September 2021 2 August 2021 2 July 2021 2 June 2021 1 May 2021 1 April 2021 2 March 2021 2 February 2021 2 January 2021 2 December 2020 2 November 2020 4 October 2020 1 September 2020 3 August 2020 2 July 2020 1 June 2020 2 May 2020 1 April 2020 1 March 2020 1 February 2020 1 January 2020 1 December 2019 1 November 2019 1 October 2019 1 May 2019 1 February 2019 1 December 2018 2 November 2018 1 October 2018 4 September 2018 1 August 2018 1 July 2018 1 June 2018 3 April 2018 3 March 2018 3 February 2018 3 January 2018 2 December 2017 1 April 2017 1 March 2017 7 December 2016 1 November 2016 2 October 2016 1 September 2016 4 August 2016 1 June 2016 1 May 2016 3 April 2016 1 August 2015 1 April 2015 10 August 2014 1 July 2014 1 June 2014 2 May 2014 2 February 2014 1 January 2014 2 October 2013 1 September 2013 2 August 2013 2 June 2013 5 May 2013 2 March 2013 1 February 2013 1 January 2013 1 December 2012 2 November 2012 2 September 2012 2 July 2012 1 May 2012 3 April 2012 2 March 2012 2 January 2012 1

Tags