How to call GetDataFromExcelPC function
Here’s a sample code illustrating how to use the GetDataFromExcelPC function:
function NormalizeData(schoolFolder) { var spread, classSpread, row, book = [], splitChar = ";"; var excelFiles = schoolFolder.getFiles("*.xlsx"); if (excelFiles.length == 0) { return null; } var excelFile = excelFiles[0]; // get the 1st excel file: the name doesn't matter var excelFilePath = excelFile.fsName.replace(/\\/g, "\\\\"); // Get data from Excel try { for (var i = 0; i < totalClassesNumber; i++) { spread = GetDataFromExcelPC(excelFilePath, splitChar, i + 1); if (spread.length > 0 && spread[1][2] != "") { // returned not empty array and child name isn't blank spread.shift(); // remove the header for (var j = 0; j < spread.length; j++) { row = spread[j]; if (row[2] == "") { spread.splice(j, spread.length - j); break; } else { row[0] = RemoveSuperfluousSpaces(row[0].toUpperCase()); // P/L to uppercase row[1] = RemoveSuperfluousSpaces(row[1]); // Created by row[2] = RemoveSuperfluousSpaces(row[2]); // Child Name row[3] = RemoveSuperfluousSpaces(row[3]); // of row[4] = RemoveSuperfluousSpaces(row[4]); // Class Name row[5] = RemoveSuperfluousSpaces(row[5]); // School Name row[6] = RemoveSuperfluousSpaces(row[6]); // Order Deadline row[7] = RemoveSuperfluousSpaces(row[7]); // Payment Instructions } } book.push(spread); //$.writeln(i + 1 + " - " + spread.toString()); } else { // No more spreadsheets left to process //$.writeln("No more spreadsheets left to process."); break; } } } catch(err) { $.writeln(err.message + ", line: " + err.line); } countClasses = book.length; return book; }