Page 3 of 3
Re: At last I reached the harbour
Posted: Fri Jul 21, 2017 8:42 pm
by ROBROS
Hi Marek,
read your post just now, how do I do that and is it working for xlsx too? (csv?)
Robert
Re: At last I reached the harbour
Posted: Sat Jul 22, 2017 11:35 am
by mol
I don't understand question...
Re: At last I reached the harbour
Posted: Sat Jul 22, 2017 12:29 pm
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
Re: At last I reached the harbour
Posted: Sat Jul 22, 2017 1:55 pm
by mol
You must have Excel installed, too.
Re: At last I reached the harbour
Posted: Sat Jul 22, 2017 8:50 pm
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
Re: At last I reached the harbour
Posted: Sat Jul 22, 2017 9:26 pm
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
Re: At last I reached the harbour
Posted: Sun Jul 23, 2017 6:05 am
by serge_girard
Robert,
This is not via ActiveX. ActiveX (see examples) is used with webpages-url-internet etc.
Serge