0

I have a C++ application which calls the business logic and generates a CSV that contains different transaction data.

Business partner wants to have this CSV as an Excel file and with different formatting options such as headers with bold text and numbers formatting with commas, etc.

I can not find any option to do this in c++ but found that I can convert the CSV file to Excel using PowerShell. I am finding the below difficulty in PowerShell:

  • Though the amount fields are in number format - I can not see the result as "1,234,56.00". It just shows like 123456 only. But when I check the format option it shows 1,234.10.. I have added the line in PowerShell as below:

    $worksheet.columns.item(2).NumberFormat = "#,##0.00_);[Red](#,##0.00)"

  • I have multiple sections in the same work sheet with multiple header sections. I need to format some of the texts in bold. I can change the format to bold as below.

    $worksheet.Range("1:1").Font.Bold = $True

But the issue for me is the report will generate different numbers of records based transaction details. So I can't take the cell range and decide to format statically.

henrycarteruk
  • 12,708
  • 2
  • 36
  • 40
user1706047
  • 369
  • 3
  • 7
  • 19

2 Answers2

0
  1. Import you csv with import-csv command
  2. Modify your column values with good format (cast, substring etc) into loop
  3. Export into other temporary csv
  4. Transform your temporary csv in Excel. You will found lot of code here
Community
  • 1
  • 1
Esperento57
  • 16,521
  • 3
  • 39
  • 45
0

There is an excellent module for Excel here by Douge Finke

Regards,

Kvprasoon

Prasoon Karunan V
  • 2,916
  • 2
  • 12
  • 26