web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How i can get the tabl...
Power Automate
Suggested Answer

How i can get the tables that got created as part of an excel script

(0) ShareShare
ReportReport
Posted on by 2,015 Season of Giving Solutions 2025
I have added this script inside my excel document which is uploaded inside sharepoint:-
function main(
  workbook: ExcelScript.Workbook
) {
  const template = workbook.getWorksheet('TemplateDoNotDelete');
  if (!template) {
    throw new Error(`Template sheet was not found.`);
  }

 

  const copiedSheet = template.copy(
    ExcelScript.WorksheetPositionType.after,
    template
  );

 

  copiedSheet.setName('123');

 

  return `Created worksheet: $`;
}
Then i called this script which will create a new excel worksheet which contain 3 tables. now how i can get the tables that were created by the sript inside my flow? Thanks
I have the same question (0)
  • CU27030035-0 Profile Picture
    105 on at
    Not sure if you can do that 
    But you could create the tables and Spread sheet using power automate which would then present as outputs to be used later in the flow
    Store the Template file in wither SharePoint or One drive
    Use a get File Content (or get file content using path) to point at your template 
    then create a file and use the file content from the previous step to create it the same as your template 
     
    Then use a create tables and point it at the output from the previous step
  • Suggested answer
    Sunil Kumar Pashikanti Profile Picture
    2,318 Moderator on at
     
    There are two ways for this. 
    1) Get the table names dynamically from the script (OR)
    2) If you know the table names, use them directly.

    1st approach:
    Office Scripts can create worksheets and tables, but Power Automate cannot directly “see” script objects unless you expose them explicitly.
    You must return table information from the script itself, then use that output in Power Automate.

    How it works (high level)
    1) Update the Office Script to:
          Get the tables from the newly created worksheet
          Return table names (or IDs) as output

    2) In Power Automate:
          Use the Run script action
          Read the returned table names
          Use standard Excel actions like List rows present in a table

    Recommended Script Change (Example)
    function main(workbook: ExcelScript.Workbook) {
      const template = workbook.getWorksheet('TemplateDoNotDelete');
      if (!template) {
        throw new Error('Template not found');
      }
      const copiedSheet = template.copy(
        ExcelScript.WorksheetPositionType.after,
        template
      );
      copiedSheet.setName('123');
      const tables = copiedSheet.getTables();
      const tableNames = tables.map(t => t.getName());
      return {
        worksheetName: copiedSheet.getName(),
        tableNames: tableNames
      };
    }
    Power Automate receives:
    New worksheet name
    List of table names created or copied
     
    Power Automate Flow Steps (Simple)
    1. Use Run script (Excel Online Business)
    2. Capture output from the script
    3. Loop over tableNames
    4. Use List rows present in a table
    5. Pass table name dynamically
    This is the only supported and reliable method.

    2nd approach
    Step-by-Step Implementation in Power Automate
    1. Run script: Connect your script.
    2. Initialize Variable (Optional): Or just use the output directly.
    3. Excel Online (Business) Actions:
      1. In the Table field of any Excel action, do not use the dropdown.
      2. Select Enter custom value.
      3. Select the tableNames (or the specific string) from the Dynamic Content of the "Run script" step.
     

    ✅ If this answer helped resolve your issue, please mark it as Accepted so it can help others with the same problem.
    👍 Feel free to Like the post if you found it useful.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard