Hi,
It has been a while since the last time I sought for help. I have been testing a power automate flow which only job is to fetch information from a csv file to an excel file... the last activity of the workflow calls the 'run scripts' step which triggers an excel office script from an excel template. The flow works with files =< 6K rows, but fails when the rows exceed that count. Based on documentation, I became aware that this is a limitation, but that there is a way to work around it by copying the data in smaller batches.
The only problem is that the person that suggested the solution and showed how to do it... did it with randomly generated data and not with an actual file.
The video can be watched here => copy_in_batches_video
His script for copying data in batches is here => copy_in_batches_script
This is the script I'm currently using in my flow... so my plead is... does anyone know Excel office script and how to integrate the script below with his script to be able to copy larger files?
It has been a while since the last time I sought for help. I have been testing a power automate flow which only job is to fetch information from a csv file to an excel file... the last activity of the workflow calls the 'run scripts' step which triggers an excel office script from an excel template. The flow works with files =< 6K rows, but fails when the rows exceed that count. Based on documentation, I became aware that this is a limitation, but that there is a way to work around it by copying the data in smaller batches.
The only problem is that the person that suggested the solution and showed how to do it... did it with randomly generated data and not with an actual file.
The video can be watched here => copy_in_batches_video
His script for copying data in batches is here => copy_in_batches_script
This is the script I'm currently using in my flow... so my plead is... does anyone know Excel office script and how to integrate the script below with his script to be able to copy larger files?
JavaScript:
function main(workbook: ExcelScript.Workbook, csv: string) {
let sheet = workbook.getWorksheet("Sheet1");
/* Convert the CSV data into a 2D array. */
// Trim the trailing new line.
csv = csv.trim();
// Split each line into a row.
let rows = csv.split("\r\n");
rows.forEach((value, index) => {
/*
* For each row, match the comma-separated sections.
*/
let row = value.match(/(?:,|\n|^)("(?:(?:"")*[^"]*)*"|[^",\n]*|(?:\n|$))/g);
// Remove the preceding comma.
row.forEach((cell, index) => {
row[index] = cell.indexOf(",") === 0 ? cell.substr(1) : cell;
});
// Create a 2D-array with one row.
let data: string[][] = [];
data.push(row);
// Put the data in the worksheet.
let range = sheet.getRangeByIndexes(index, 0, 1, data[0].length);
range.setValues(data);
});
// Credit to AlexJerabek => https://docs.microsoft.com/en-us/office/dev/scripts/resources/samples/convert-csv
}