CSV from Excel Automation

navuser1navuser1 Member Posts: 1,329
Dear All,

A dataport is customized to create a csv file. After that a third party tool consumes this csv file for internal use.
Dataport has the following propertities .
1. FieldStartDelimiter =<">
2. FieldSeparator = |

As dataport is not acceptable in NAS environment & the client does not have xmlport executable permission in their license. So,
I have given a task to generate the same csv file without using any dataport/xmlport.

To do this I have created a Codeunit to generate the same csv file using Excel Automation in same database. I have checked the csv files generated from the codeunit is perfectly matching with the dataport generated csv file.

But the 3rd Party software is not accepting the codeunit generated csv files due to find inappropiate character in the files. :shock:

How does the 3rd Party Software see the codeunit generated files is given in an attachment files.


How to solve this type of issues ?
Now or Never

Comments

  • eyolfthoeyolftho Member Posts: 18
    How did you verify that the 2 files are identical? By opening them in excel?...then they will look identical
    Check in Notepad..
    | is not av valid field separator in csv format...Excel therefore consider the |-s to be alfanumerical fields, and add "" around them before saving the file.

    If you use Excel Automation to generate the file, and save the file via .SaveAS method, excel will add the "'s

    Save the file via File or OutStream instead
  • navuser1navuser1 Member Posts: 1,329
    Thanks for reply.

    Files are similar in Excel view only.
    As per the requirement of the third party tool we have to consider the | as a field separate.

    I hope C/AL can do the same task as dataport can do.

    Using Excel Automation & SaveAs(FileName,6) function I am trying to achieve the same.
    Now or Never
  • navuser1navuser1 Member Posts: 1,329
    Thanks for reply.

    Files are similar in Excel view only.
    As per the requirement of the third party tool we have to consider the | as a field separate.

    I hope C/AL can do the same task as dataport can do.

    Using Excel Automation & SaveAs(FileName,6) function I am trying to achieve the same.
    Now or Never
  • vaprogvaprog Member Posts: 1,140
    If you want to use Excel, you'll have to put up with whathever Excel considers CSV, or try to coerce excel into doing what you want, but mind, Excel can be very stubborn.

    So, along with eyolftho, I strongly advise to use outstream and it's TEXTWRITE function (It's much more reliable and more easy to control that FILE's TEXTMODE WRITE).

    Forget about excel, both, as a means to create the file and as a means to verify it.
Sign In or Register to comment.