FW_ExcelToDBF - (2015) Import procedure from Excel not run

Post Reply
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

FW_ExcelToDBF - (2015) Import procedure from Excel not run

Post by Silvio.Falconi »

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

  @ 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

 
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
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Maurizio
Posts: 705
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

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

Post by Maurizio »

I think it's a Harbor problem like this ,

https://forums.fivetechsupport.com/view ... io#p225822

try with xHarbour

Maurizio
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

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

Post by Silvio.Falconi »

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

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
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

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

Post by Silvio.Falconi »

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?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Post Reply