At last I reached the harbour

New members who wish to post and participate in HMG Forum, please introduce yourselves in this forum by starting a new thread.

Moderator: Rathinagiri

ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: At last I reached the harbour

Post by ROBROS »

Hi Marek,

read your post just now, how do I do that and is it working for xlsx too? (csv?)

Robert
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: At last I reached the harbour

Post by serge_girard »

Hi Robert,

Is this what you mena/want?

Code: Select all

#include <hmg.ch>

Function Main

   DEFINE WINDOW Win_1 ;
      ROW 0 ;
      COL 0 ;
      WIDTH 440 ;
      HEIGHT 240 ;
      TITLE 'Excel to DBF' ;
      MAIN
      
      ON KEY ESCAPE ACTION  Win_1.Release        
        
      DEFINE MAIN MENU
         DEFINE POPUP "Conversion"
            MENUITEM 'Import Excel data' ACTION ImportData()
         END POPUP
      END MENU
        
   END WINDOW
   Win_1.Center
   Win_1.Activate

Return

Function ImportData
   LOCAL oExcel, oWorksheet, i

   IF ! MsgYesNo('Start to process?','Confirm')
      return
   endif   

   oExcel := CreateObject( "Excel.Application")
   oExcel:Workbooks:Open( GetCurrentFolder()+"\newshop.xls" )    // here right name 
   oExcel:Visible := .t.
   sele a
   use shoptype
   zap
   
   for i = 4 to 7   // here
      cTypeO=oExcel:WorkSheets(1):cells(i,2):value
      cTypeN=oExcel:WorkSheets(1):cells(i,3):value
      cCustCode=left(oExcel:WorkSheets(1):cells(i,4):value,6)
      cCustName=subs(oExcel:WorkSheets(1):cells(i,4):value,8,50)
      appe blank
      repl typeo with cTypeO, typen with cTypeN, cust_code with cCustCode, cust_name with cCustName
   next
   close databases
Return
You only need to adjust xls-name, dbf-name plus all field names.

Serge
There's nothing you can do that can't be done...
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: At last I reached the harbour

Post by ROBROS »

Hi,

@ Marek: in my office at work I use excel, at home I use free office,

@ Serge: that is via activeX ? I will have a look at this, never used that before, right now I am glad with append from sdf. Have to learn so much new things, but the app I am programming shows progress.

Thank you
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: At last I reached the harbour

Post by ROBROS »

BTW: I have opened a topic in "HMG Tutorial and Tips". Title: "How do I call a procedure" and I got useful answers, what I mean, I should not have used the self-introduction area to post problems, my fault.

Robert
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: At last I reached the harbour

Post by serge_girard »

Robert,

This is not via ActiveX. ActiveX (see examples) is used with webpages-url-internet etc.

Serge
There's nothing you can do that can't be done...
Post Reply