[Résolu][Calc] Import CSV ou TXT et séparateur point-virgule

Discussions et questions sur tout ce qui concerne la programmation tous langages et tous modules confondus.

Modérateur : Vilains modOOs

Règles du forum
:alerte: Balisage obligatoire dans cette section !
Aidez-nous à vous aider au mieux en balisant correctement votre question : reportez-vous sur les règles de cette section avant de poster !
bletraon
Fraîchement OOthentifié
Messages : 3
Inscription : 09 oct. 2006 09:26

[Résolu][Calc] Import CSV ou TXT et séparateur point-virgule

Message par bletraon »

Bonjour,
Sous WIN2000 et OpenOffice 2.O.4,
après de longues heures de recherches sur de nombreux forums et documents en ligne, j'ai un petit souci quant à l'ouverture, par une MACRO, d'un fichier CSV, avec des séparateurs ";" et dont toutes les colonnes doivent être importées au format "texte" et non "standard". Je me suis donc inspiré de la macro proposée par JY SAMIN:

Code : Tout sélectionner

             txtOptions(0).Name = "FilterName"
             txtOptions(0).Value = "Text - txt - csv (StarCalc)"
             txtOptions(1).Name = "FilterOptions"
             txtOptions(1).Value = " 44, ANSI, 1, 1"   
                       
             otextdoc= StarDesktop.loadComponentFromURL(txtAdresse, "_blank", 0, txtOptions())
dans laquelle j'ai compris que la valeur "44" du "FilterOptions" correspond à la ",". Quant au dernier argument de valeur "1" il s'agit de la valeur "Standard" repérée dans une autre message du forum. "ANSI", facile, le 3ème argument me semble-t-il correspond à la valeur doublequote qui peux encadrer une valeur. A confirmer. J'ai donc remplacé la valeur "44" par la valeur "59" (";"), le fichier s'importe correctement mais en valeurs "standard".
Bref existe-t-il une information qui puisse m'indiquer les valeurs possibles de chaque argument de ce satané "FilterOptions".
D'avance je vous en remercie.
Win XP SP2 - UBUNTU
bletraon
Fraîchement OOthentifié
Messages : 3
Inscription : 09 oct. 2006 09:26

[Resolu] Import CSV en format "TEXTE" et séparateu

Message par bletraon »

Re-Bonjour, j'ai continué à chercher et dans le developpesguide 2.0, page 590 j'ai TROUVE. Je met donc ci-dessous les principales valeurs des arguments possibles.

Example Filter Options
String Field Separator (1)
Text Delimiter (2)
Character Set (3)
Number of First Line (4)
Cell Format Codes for the four Columns (5)
1. Field separator(s) as ASCII values. Multiple values are separated by the slash sign (“/”), that is, if the values are separated by semicolons and horizontal tabulators, the token would be 59/9.
To treat several consecutive separators as one, the four letters /MRG have to be appended to the token. If the file contains fixed width fields, the three letters FIX are used.
2. The text delimiter as ASCII value, that is, 34 for double quotes and 39 for single quotes.
3. The character set used in the file as described above.
4. Number of the first line to convert. The first line in the file has the number 1.
5. Cell format of the columns. The content of this token depends on the value of the first token.
• If value separators are used, the form of this token is column/format[/column/format/...]
where column is the number of the column, with 1 being the leftmost column. The
format is explained below.
• If the first token is FIX it has the form start/format[/start/format/...], where start is the
number of the first character for this field, with 0 being the leftmost character in a line.
The format is explained below.
Format specifies which cell format should be used for a field during import:
Format Code Meaning
1 Standard
2 Text
3 MM/DD/YY
4 DD/MM/YY
5 YY/MM/DD
6 -
7 -
8 -
9 ignore field (do not import)
10 US-English
The type code 10 indicates that the content of a field is US-English. This is useful if a field
contains decimal numbers that are formatted according to the US system (using “.” as decimal
separator and “,” as thousands separator). Using 10 as a format specifier for this field


A plus
Win XP SP2 - UBUNTU
Verrouillé