Here's a simple example that reads from a CSV file, chops the data into rows and columns, and then writes it to an Ebase table:
Code: Select all
importPackage(com.ebasetech.xi.api);
importPackage(com.ebasetech.xi.services);
// read the csv
var m = FileServices.readFile("C:/tms_certificates/spreadsheet/matrix.csv");
// put each line in an array cell
var lines = m.split(/\r\n|\n/);
// process each line in the array into an Ebase table, skipping the first one (the header)
for (var i=1; i<lines.length; i++) {
// put each comma seperated field into an array cell
var data = lines[i].split(',');
// insert table row
tables.CERTIFICATES.insertRow();
tables.CERTIFICATES.COMPANY.value=data[0];
tables.CERTIFICATES.TRAINING_DATE.value=data[1];
tables.CERTIFICATES.DELEGATE_NAME.value=data[2];
tables.CERTIFICATES.CERT_NO.value=data[3];
tables.CERTIFICATES.COURSE_TITLE.value=data[4];
tables.CERTIFICATES.INSTRUCTOR.value=data[5];
tables.CERTIFICATES.SITE.value=data[6];
tables.CERTIFICATES.EXT_CERT_CARD_NO.value=data[7];
tables.CERTIFICATES.EXPIRY_DATE.value=data[8];
}
// scroll to the first line in the table
controls.C.scrollToTop();[code][/code]