Import/export Excel files - Funziona!!

Forum dedicato ai programmatori di X# in lingua italiana – Italian language forum

Moderator: wriedmann

User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Import/export Excel files - Esempio ok!

Post by wriedmann »

Ciao Gian Ferruccio,
un interfaccia in X# non può essere instanziata. Perciò devi scrivere

Code: Select all

XlsxFile{}
invece di

Code: Select all

IXlsxFile{}
per creare l'oggetto.
Per quanto riguarda LenNum(): devo ammettere che questa funzione non la ho mai usato, anche se esiste nell'aiuto di VO.
Sembra non esistere in X#. Chiediamo a Chris.
@Chris: the LenNum() function exists in my VO help file, but does not exists in my X# help file and the compiler does not find it. Could you check, please?
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Import/export Excel files - Esempio ok!

Post by wriedmann »

Ciao Gian Ferruccio,
la funzione LenNum() è definita nella libreria System di VO come segue:

Code: Select all

FUNCTION LENNUM     (n AS USUAL)  AS DWORD    PASCAL
    RETURN SLen(NTrim(n))
Aggiungi questa funzione nel tuo applicativo fino a quando verrà aggiunta nella runtime di X#.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Gfb22
Posts: 105
Joined: Sat Oct 08, 2022 7:43 pm
Location: Italy

Import/export Excel files - Esempio ok!

Post by Gfb22 »

....se sostituisco, VO non compila e nella riga:
oXlsxFile := XlsxFile{}
mi da l'errore:
"Unknown CLASS XLSXFILE{}" / " Bad object creator syntax in XLSXFILE{}...
------------------
Per LENNUM pensavo già, in effetti, di trasformare il numero in stringa e misurare la lunghezza con LEN...
Grazie!
gfb
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Import/export Excel files - Esempio ok!

Post by wriedmann »

Ciao Gian Ferruccio,
in VO devi lasciare IXlsxFile{}, in X# deve essere XlsXFile{}. Ma gli errori che hai fatto vedere non erano VO, ma X#.
Se hai del codice che vuoi portare devi fare così:

Code: Select all

#ifdef __XSHARP__
oXls := XlsxFile{}
#else
oXls := IXlsxFile{}
#endif
In questo modo il compilatore VO prende la riga destinata a lui, e quello X# quella corretta per X#.
Saluti
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Gfb22
Posts: 105
Joined: Sat Oct 08, 2022 7:43 pm
Location: Italy

Import/export Excel files - Esempio ok!

Post by Gfb22 »

...scusami ancora Wolfgang...
- Risolto LENNUM, restano gli altri, anche se leggermente diversi.
Ho prima dichiarato la variabile come Object:
local oXlsxFile        as object 
ed ecco il codice che da errore:
 
err1.jpg
err1.jpg (30.32 KiB) Viewed 1331 times
Infine gli errori:

Code: Select all

 error XS0246: The type or namespace name 'XlsxFile' could not be found (are you missing a using directive or an assembly reference?)    91,17    Start_Excel.prg    StandardShellWindow:SalvaDBF
error XS0246: The type or namespace name 'XlsxFile' could not be found (are you missing a using directive or an assembly reference?)    188,18    Start_Excel.prg    StandardShellWindow:SalvaXLSX
Compilation failed (2 errors, 5 warnings)
Sto sbagliando qualcosa ma non so cosa... :-)
Grazie ancora!
​​​​​​​gfb

 
gfb
User avatar
Gfb22
Posts: 105
Joined: Sat Oct 08, 2022 7:43 pm
Location: Italy

Import/export Excel files - Esempio ok!

Post by Gfb22 »

#Robert, #Chris: #Fabrice: New WebSite.
we can get away with it but the previous site was much better.
I use Chrome as a browser and I often have to refresh the page because a part of the site 'disappears' regardless of the zoom.
Furthermore, the login works only from the homepage and page loading is often slow.
However we still manage to use it and thanks for all your work! :-)
gfb
gfb
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Import/export Excel files - Esempio ok!

Post by wriedmann »

Ciao Gian Ferruccio,
in teoria, se hai aggiunto il

Code: Select all

using XSharp.Tools.XlsxFile
in testa al file Start_Excel.prg questo e hai incluso la libreria XSharp.Tools.XlsxFile.dll tra le referenze non ti dovrebbe dare questi errori.
Se il problema non si risolve, magari posso vedere in teleassistenza. Domani sera torno sul tardi, non prima delle 20:15, ma sono in ufficio il giovedì mattina dalle 7 alle 11 circa e poi la sera dopo le 18.
Saluti
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Gfb22
Posts: 105
Joined: Sat Oct 08, 2022 7:43 pm
Location: Italy

Import/export Excel files - Esempio ok!

Post by Gfb22 »

Buongiorno Wolfgang.
..se non risolvo e per te ok, benissimo in teleassistenza domani, giovedì, quando vuoi (prima delle 9 andrebbe benissimo).
Grazie!
gfb
gfb
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Import/export Excel files - Esempio ok!

Post by wriedmann »

Ciao Gian Ferruccio,
se non risolvi, mandami una mail che possiamo metterci d'accordo su come fare.
Saluti
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Gfb22
Posts: 105
Joined: Sat Oct 08, 2022 7:43 pm
Location: Italy

Import/export Excel files - Esempio ok!

Post by Gfb22 »

...Ho provato a eliminare del tutto la mia app da XIDE; l'ho nuovamente portata e aggiunta; controllato le references e aggiunto using XSharp.Tools.XlsxFile
all'inizio del file Start_Excel.prg e ...
FUNZIONA!
Anche se non mi spiego perché non funzionasse prima.
Provato le diverse funzioni e funziona ma, unico problema, scrivendo un file xlsx da DBF, i campi numerici sono formattati come testo in XLSX e, quindi, non consentono (se non lavorando poi sul file di Excel) di fare calcoli.
La cosa strana è che invece, usando lo stesso file DBF e facendo l'esportazione in Excel con VO, il file di Excel è giusto.
Per completezza e spiegarmi meglio, allego il file DBF originale e i due file XLSX prodotti con VO o con #X.

​​​​​​​ 
TEMP.zip
(26.21 KiB) Downloaded 120 times
gfb
Post Reply