Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Solutions
Beiträge im Thema:
4
Erster Beitrag:
vor 9 Jahren, 4 Monaten
Letzter Beitrag:
vor 4 Jahren, 9 Monaten
Beteiligte Autoren:
edmundo, Allard, Grand77, DarrenF

Importing Data from Excel (XLS) file to HF

Startbeitrag von DarrenF am 26.02.2009 16:41

All,

An example of importing data from an Excel file to a HF file - this example imports the ISO Countries data (Countries data sourced from the ISO standards web site).

This was originally posted on the main WD forum, but thought it may be useful here as well:


IDXLSFile is int
iNo_rows is int
glocaliIResult is int

// Open the Currencies excel file
IDXLSFile = xlsOpen("c:\My Projects\InterPoint\Extract Files for Import\currencies.xls")

// If the Excel file was found, then carry on processing
// ELSE
// Report an error
IF IDXLSFile -1 THEN

// Get number of rows in the Excel file
iNo_rows = xlsNbRow(IDXLSFile)

// Test for existence of Country table
IF NOT HOpen(Country,hOReadWrite) THEN
Error("Unable to locate the required Country database table!")
RETURN
END

// HCreation will delete and re-create these tables and also reset all the rec no's and auto IDs
HCreation(Country)

// Process each row of the Excel file
// Start at row 2 to ignore the Excel title row...
FOR glocaliNV_Row = 2 TO iNo_rows

// Country Details
Country.cCountryCode = xlsData(IDXLSFile,glocaliNV_Row,1)
Country.cCountryName = xlsData(IDXLSFile,glocaliNV_Row,5)
Country.cCurrencyCode = xlsData(IDXLSFile,glocaliNV_Row,2)
Country.nCurrencyCode = xlsData(IDXLSFile,glocaliNV_Row,3)
Country.cCurrencyDesc = xlsData(IDXLSFile,glocaliNV_Row,4)
Country.bActiveCountry = xlsData(IDXLSFile,glocaliNV_Row,6)
Country.bActiveCurrency = xlsData(IDXLSFile,glocaliNV_Row,7)
Country.cCurrencySymbol = ""
Country.dtCreated = DateSys + TimeSys
Country.cNotes = "Auto loaded from ISO import file on " + DateToString(DateSys())

// Write the data to the database
HAdd(Country)

END

// Close XLS file
xlsClose(IDXLSFile)

ELSE
Info(xlsMsgError(IDXLSFile))

END

Antworten:

Thanx a lot

von Grand77 - am 24.11.2009 23:37
Hi

Does excel need to be installed on the users computer to use this method

Thanks for the code!!

Allard

von Allard - am 09.02.2011 15:14
gracias por tu aporte me dio mucha ayuda

von edmundo - am 02.10.2013 19:51
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.