FW_ExcelToDBF - (2015) Import procedure from Excel not run

FW_ExcelToDBF - (2015) Import procedure from Excel not run

Postby Silvio.Falconi » Tue Nov 26, 2019 11:16 am

On 2015 I had done a procedure to convert the school timetable from Excel into a personal DBF archive.

Now that function no longer turns good.

I didn't make any changes to that file.

I just recompiled my procedure with the new fwh

How is this possible? after 4 years the conversion procedure does not work?


I explain you what I made on source code, perhaps there is something changed ..

Before load the file xls

Code: Select all  Expand view
 @ 0,7 SAY  i18n( "Introdurre il file " )     OF oDlgExcel
         @ 1,2 SAY  i18n( "File Xls :" )     OF oDlgExcel

         @ 1.3,6 GET aGet[1] VAR cFileXls PICTURE "@!"  OF oDlgExcel  SIZE 150, 11 UPDATE

         bLook := { | |cFileXls:= GetfileXls(),aGet[1]:refresh()}



Image





then Open the file Import.dbf where save the xls and convert the file xls into

Code: Select all  Expand view

IF oDlgExcel:nresult == IDOK
               IF!Empty(cFileXls)
                  oRange := GetExcelRange(cFileXls , , @lOpened)
                   IF ! Db_Open("Import","TM")
                      lReturn:=.f.
                      MsgAlert("Non riesco a connettermi con gli archivi")
                   else
                      SELECT TM
                      //xbrowse()
                       Dbzap()
                       IF  FW_ExcelToDBF( oRange, nil, .t. )
                             lreturn :=.t.
                          ENDIF
                       TM->(dbclosearea())
                    ENDIF
                    oRange := NIL
                 else
                    MsgAlert("non riesco a trovare il file excel")
                ENDIF
        ENDIF
 


What has been changed?


Now it convert the xls in this mode :

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7053
Joined: Thu Oct 18, 2012 7:17 pm

Re: FW_ExcelToDBF - (2015) Import procedure from Excel not run

Postby Maurizio » Wed Nov 27, 2019 7:59 am

I think it's a Harbor problem like this ,

viewtopic.php?f=3&t=37773&p=225822&hilit=maurizio#p225822

try with xHarbour

Maurizio
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Re: FW_ExcelToDBF - (2015) Import procedure from Excel not run

Postby Silvio.Falconi » Wed Nov 27, 2019 8:04 am

yes
On xharbour run ok


BUt on Harbour you made
oRange := GetExcelRange(cFileXls , , @lOpened)
and then
Xbrowse(oRange)
run ok I see all datas

So, the problem is of Fw_ExcelToDbf()

Please Maurizio try this
testxbrowse(oRange)
Code: Select all  Expand view
Function  testxbrowse(oRange)
   Local oDlg,oBrowse
   Local oBtnDbf

    DEFINE DIALOG oDlg TITLE "TEST EXCEL." SIZE 400,400 ;
             PIXEL TRUEPIXEL RESIZABLE

   @ 1,2 xbrowse oBrowse ARRAY oRange  ;
   SIZE 100,62 PIXEL STYLE FLAT NOBORDER


                   WITH OBJECT oBrowse
                       :nRowHeight    := 25
                      :lDrawBorder      := .t.
                      :lHscroll         := .F.
                      :l2007            := .F.
                      :l2015            := .T.
                      :nStretchCol      := STRETCHCOL_WIDEST
                      :nColDividerStyle := LINESTYLE_LIGHTGRAY
                      :lAllowRowSizing     := .F.
                      :lAllowColSwapping   := .F.
                      :lAllowColHiding     := .F.
                      :nMarqueeStyle       := MARQSTYLE_HIGHLROWMS
                      :CreateFromCode()
                   END

                   @ 1,2 button oBtnDbf Prompt "Conversione" size 120,20 ;
                   of oDlg action oBrowse:ToDbf("test.dbf")
                 oDlg:bResized  := <||
                local oRect    := oDlg:GetCliRect()
                      oBrowse:nTop      := oRect:nTop+10
                      oBrowse:nHeight    := oRect:nBottom-60
                      oBrowse:nWidth    := oRect:nRight-2
                      oBtnDbf:ntop       := oRect:nBottom - 40
                      oBtnDbf:nleft      :=  oRect:nRight - 140
                    return nil
                  >

     ACTIVATE DIALOG oDlg CENTERED;
                  ON INIT ( EVAL(oDlg:bResized ) )
   RETURN NIL




 


it read the excel ->show on xbrowse -> converte to dbf

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7053
Joined: Thu Oct 18, 2012 7:17 pm

Re: FW_ExcelToDBF - (2015) Import procedure from Excel not run

Postby Silvio.Falconi » Wed Nov 27, 2019 9:24 am

Resolved but also not run ok

put at the end of the function FW_ExcelToDbf before

lRet: = FW_ArrayToDBF (adata, If (Empty (cFieldList), If (Empty (aHead), nil, aHead), cFieldList), bProgress)

this line

aData: = ArrTranspose (aDATA)

only there is another problem on FW_ArrayToDBF because take only bad column

I explain

if in the excel sheet there are only some fields and in the dbf instead there are others
the function FW_ArrayToDBF takes the wrong fields.
How do I check with the right fields?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7053
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Jimmy and 84 guests