How to import a csv-file in UTF8-code into Navision ?

Jochen
Member Posts: 5
I like to import a csv-file containing sales order data into the Navision tabels Sales Header and Sales Line. My interface using a dataport worked fine until the codepage of the files have been switched from ASCII to UTF8.
Does anybody know, how to convert a UTF8-coded file into an ANSI or ASCII-coded file ?
I tried already to open the file within a report via Excel and save it again with the OpenText- and SaveAs-methods of Excel (see the follwing code).
IF ISCLEAR(Excel) THEN CREATE(Excel,FALSE);
Excel.Visible(TRUE);
Excel.Workbooks.OpenText(FileName, //Dateiname
65001, //Codepage UTF8
1, //Startrow
1, //Excel.Workbooks.XlTextParsingType.xlDelimited
//Konstante für den variable dateityp CSV-Datei
3, //Excel.XLTextQualifier.xlTextQualifierNone
//Konstante für den Feldbegrenzer
FALSE, //Aufeinanderfolgende Trennzeichen als ein Zeichen behandeln?
FALSE, //Kein Tab als Trennzeichen
TRUE, //Semikolon als Trennzeichen
FALSE, //Kein Komma als Trennzeichen
FALSE, //Kein Space als Trennzeichen
FALSE); //Kein anderes Trennzeichen
Book := Excel.ActiveWorkbook;
Book.SaveAs(FileName, //Dateiname
6, //Dateiformat: 6 = CSV-Datei
'', //Password für Leseschutz
'', //Password für Schreibschutz
FALSE, //ReadOnlyRecommended: falls True wird beim Öffnen eine Schreibschutzabfrage
//eingeblendet
FALSE, //CreateBackup: Falls True wired eine Sicherungskopie erstellt
1, //XLSaveAsAccessMode: Speichert den Öffnen-Modus einer Datei
//Der Wert 1 für Standard, d.h. den Modus beim Speichern nicht ändern
2); //XlConfictResolution: Der Wert 2 für "Akzeptiere die Änderungen"
Excel.Quit;
CLEAR(Excel);
But i couldn't automate this indirect way, because I couldn't find a method to suppress the standard user dialog windows, which Excel uses to submit confirm messages to the user.
Has anybody a better idea ?
Jochen Anderko
Does anybody know, how to convert a UTF8-coded file into an ANSI or ASCII-coded file ?
I tried already to open the file within a report via Excel and save it again with the OpenText- and SaveAs-methods of Excel (see the follwing code).
IF ISCLEAR(Excel) THEN CREATE(Excel,FALSE);
Excel.Visible(TRUE);
Excel.Workbooks.OpenText(FileName, //Dateiname
65001, //Codepage UTF8
1, //Startrow
1, //Excel.Workbooks.XlTextParsingType.xlDelimited
//Konstante für den variable dateityp CSV-Datei
3, //Excel.XLTextQualifier.xlTextQualifierNone
//Konstante für den Feldbegrenzer
FALSE, //Aufeinanderfolgende Trennzeichen als ein Zeichen behandeln?
FALSE, //Kein Tab als Trennzeichen
TRUE, //Semikolon als Trennzeichen
FALSE, //Kein Komma als Trennzeichen
FALSE, //Kein Space als Trennzeichen
FALSE); //Kein anderes Trennzeichen
Book := Excel.ActiveWorkbook;
Book.SaveAs(FileName, //Dateiname
6, //Dateiformat: 6 = CSV-Datei
'', //Password für Leseschutz
'', //Password für Schreibschutz
FALSE, //ReadOnlyRecommended: falls True wird beim Öffnen eine Schreibschutzabfrage
//eingeblendet
FALSE, //CreateBackup: Falls True wired eine Sicherungskopie erstellt
1, //XLSaveAsAccessMode: Speichert den Öffnen-Modus einer Datei
//Der Wert 1 für Standard, d.h. den Modus beim Speichern nicht ändern
2); //XlConfictResolution: Der Wert 2 für "Akzeptiere die Änderungen"
Excel.Quit;
CLEAR(Excel);
But i couldn't automate this indirect way, because I couldn't find a method to suppress the standard user dialog windows, which Excel uses to submit confirm messages to the user.
Has anybody a better idea ?
Jochen Anderko
New every month!
Exclusive products and attractive prizes for our newsletter subscribers.
Just sign in here:
http://www.lh-worldshop.com/newsletter-en.html
Exclusive products and attractive prizes for our newsletter subscribers.
Just sign in here:
http://www.lh-worldshop.com/newsletter-en.html
0
Comments
-
I have created a small utility in .Net to convert codepages.
It's a possible solution.0 -
Try to use CONVERTSTR function in Navision to convert "mystic" characters.0
-
nunomaia wrote:I have created a small utility in .Net to convert codepages.
It's a possible solution.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
The utility is in download section :-)
A little help how to use it can be seen in comments section of. http://dynamicsuser.net/blogs/nunomaia/ ... icode.aspx0 -
If a file is saved in the wrong type of encodingl- I usually open it in notepad and resave it using "Save As"
there you can change the encoding.
http://savatage99.googlepages.com/Encoding.JPG0 -
Yes, in the post says that.
The only new feature is the capability using automation, nothing else.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions