Forum Discussion
Raj-Microsoft-365-Dev
Apr 06, 2023Copper Contributor
Copy excel data to SharePoint List using Power Automate
Hello All, I am facing challenges in copying excel data (exist is SharePoint library) to a SharePoint list. I found few articles where it was recommended to create table inside excel to copy, but...
jonlake
Apr 08, 2023Iron Contributor
Hi Raj-Microsoft-365-Dev , you can use Power Automate to format your spreadsheet tables before the import phase. You need to have an online script available in your account (or the account running the automation). Here is an example of a script which I have used to do precisely what you're wanting to do.
function main(workbook: ExcelScript.Workbook) {
// Select the active sheet
let selectedSheet = workbook.getActiveWorksheet();
// Create a table with format on range A1:H5000 on selectedSheet
let table1 = workbook.addTable(selectedSheet.getRange("A1:H5000"), true);
table1.setPredefinedTableStyle("TableStyleLight14");
// Rename table table1 to "data"
table1.setName("data");
// Rename worksheet to "data"
selectedSheet.setName("data");
}