You don't tell us much.
Do you want to store an Excel document as a BLOB in the database or do you want to parse the contents of it and store it in the database in some tables/fields?
What is your Progress/OpenEdge version?
RealHeavyDude.
Alternatively if you save the spreadsheet as a csv with the columns in the same order as the columns in a temp-table you define you can just import the customers into a temp-table, validate them and then write them to the db.
DEFINE TEMP-TABLE tt
FIELD columnA AS CHARACTER
FIELD columnB as CHARACTER
.
INPUT FROM "c:/blaat.csv":U.
REPEAT:
CREATE tt.
IMPORT DELIMITER ",":U tt.
END.
INPUT CLOSE.
This very basic example will import a csv file with two character columns into temp-table tt. Hopefully it's enough to get you started.
Code:DEFINE TEMP-TABLE tt FIELD columnA AS CHARACTER FIELD columnB as CHARACTER . INPUT FROM "c:/blaat.csv":U. REPEAT: CREATE tt. IMPORT DELIMITER ",":U tt. END. INPUT CLOSE.
CREATE customer.
BUFFER-COPY ttcustomer TO customer.
CREATE customer.
ASSIGN
customer.company = ttcustomer.ccompany
customer.custid = ttcustomer.ccustid
etc.
Yes you can use buffer-copy if the field names are the same. First create the record:
Code:CREATE customer. BUFFER-COPY ttcustomer TO customer.
You can also assign the fields manually:
Code:CREATE customer. ASSIGN customer.company = ttcustomer.ccompany customer.custid = ttcustomer.ccustid etc.
DEFINE TEMP-TABLE ttCustomer
FIELD cCompany AS CHARACTER
FIELD cCustID as CHARACTER
FIELD cCustNum as INTEGER
FIELD cName as CHARACTER
.
INPUT FROM "C:\test\customerlist.csv":U.
REPEAT:
CREATE ttCustomer.
IMPORT DELIMITER ",":U ttCustomer.
CREATE customer.
ASSIGN
customer.company = ttCustomer.cCompany
customer.custid = ttCustomer.cCustid.
/*message ttCustomer.cCompany + ", " + ttCustomer.cCustID + ", " + ttCustomer.cName view-as alert-box.*/
END.
INPUT CLOSE.
DEFINE VARIABLE myRow AS CHAR EXTENT 5 NO-UNDO.
INPUT FROM "d:\datafile.csv".
REPEAT:
IMPORT DELIMITER ',' myrow.
FIND FIRST table1 WHERE table1.field1 = integer(myrow[1]) NO-ERROR.
IF AVAIL table1 THEN
DO:
MESSAGE "field1 alerady exist" VIEW-AS ALERT-BOX.
END.
ELSE
DO:
CREATE table1.
ASSIGN
Table1.Field1 = integer(myrow[1] )
Table1.Field2 = integer(myrow[2] )
Table1.Field3 = integer(myrow[3] )
Table1.Field4 = integer(myrow[4] )
Table1.Field5 = integer(myrow[5]) .
MESSAGE "sucess" VIEW-AS ALERT-BOX.
END.
END.