Marco Quarona ha scritto:
Buongiorno (anzi, notte) a tutti,
la nostra applicazione deve generare dei file CSV per farli aprire da Excel, per le macchine con Office, e da Calc, per quelle con Open Office. Con entrambi i programmi abbiamo qualche problemino, e con OOo in particolare c'è il "fastidio" che in automatico il programma non usa criteri di default per l'importazione, ma propone sempre la schermata con cui scegliere il carattere di separazione dei valori, il delimitatore di stringa eccetera eccetera. A noi servirebbe che l'utente possa trovarsi immediamente aperto il foglio elettronico senza dover ogni volta scegliere le opzioni di importazione.
E' possibile effettuarlo?

,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.
Marco Quarona
VB & Oracle Developer
Villanova S.p.A.
,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.
Quando mi era servito ho usato una macro con questo esempio
di StarOffice Programmer's Tutorial capitolo 4.2.1
questo ti apre il file .csv:

sub CsvSemicolon
Dim mFileProperties(1) As New com.sun.star.beans.PropertyValue
Dim sUrl As String
sUrl = ConvertToUrl("file:///home/beppe/Desktop/prove.csv")
rem se windows sUrl = ConvertToUrl(_
"C:\Documents and Settings\beppe\Desktop\prova.csv")
mFileProperties(0).Name = "FilterName"
mFileProperties(0).Value = "scalc: Text - txt - csv (StarCalc)"
mFileProperties(1).Name = "FilterFlags"
mFileProperties(1).Value = "59,34,SYSTEM,1,1/1/1/1/1/1/1/1"
oDesktop = createUNOService("com.sun.star.frame.Desktop")
oDocument = oDesktop.loadComponentFromURL(sUrl,_
"_blank",0,mFileProperties())
End Sub

per la ricerca di ulteriori approfondimenti riguardo a FileProperties:
http://docs.sun.com/app/docs?l=it

ciao
Beppe

P.S: ti allego il pezzo di pagina con le spiegazioni di FilterFlag:

To use a document that contains a foreign file format, you may have to provide the
FilterFlags property to loadComponentFromUrl( ) to ensure that the
document is imported in a certain way. A CSV file, for example, can use commas or semicolons to separate fields or it may use fields of fixed width. FilterFlags is needed to specify these details. The value of this property is a single string that contains all required information. For a CSV file, it is made up of five tokens,
separated by comma. The tokens are
1. Field separator(s) as ASCII values or the three letters FIX. If your fields are separated by commas, this token is 44, if they are separated by semicolons and tabs, the token would be 59/9. To treat several consecutive separators as one, append the four letters /MRG to this token. If the file contains fixed width fields,
use the three letters FIX as the token.
2. The text delimiter as ASCII value. Use 34 for double quotes and 39 for single
quotes.
3. The character set in the file as string.
4. Number of the first line to convert. Set this to something other then 1 if you want
to skip lines at the beginning of the file.
5. This last token is the most complicated one. Its content depends on the value of
the first token.
4 If it is FIX, this token is of the form start/format/start/format. Start
is the number of the first character for this field, with 0 being the leftmost
character in a line. Format is explained below.
4 If you are not using fixed fields but separators, the form of the last token is
no/format/no/format where no is the number of the column, 1 being the
leftmost column.
Format specifies the content of a field. It is the number 1 for standard, 2 for text,
3, 4, and 5 for date values (MM/DD/YY, DD/MM/YY, YY/MM/DD
respectively), 6, 7, and 8 for text and 9 for fields to ignore. 10 is used to indicate that the content of this field is US-English. This is particularly useful if you know
that a field contains decimal numbers which are formatted according to the US
system (using "." as decimal separator and "," as thousands separator). Using 10 as format specifyer for this field tells StarOffice API to correctly interpret its numerical content even if the decimal and thousands separator in your country
are different.
Consider a file that contains four columns: the first one contains text delimited by double quotes, the other columns contain numbers. The columns are separated by
commas. The FilterFlags for this file would be 44,34,SYSTEM,1,1/1/1/1/1/
1/1/1.

--
le nuvole non hanno regole,
perchè non hanno mai rinunciato
alla libertà di sognare.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Rispondere a