Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
ThomasWeppler
Impactful Individual
Impactful Individual

Get data out in excel

Hey Power Bi community

 

I have a customer who wants to see all my beautiful power BI reports in Excel.

Why?

I don't know, maybe their parents hit them when they was a child and now they want to take revenge on me.

What ever the reason is I helped them and told them how to download their excel file.
All was fine and good for a while, but now they want me to run this code whenever they download their excel file.

 

function main(workbook: ExcelScript.Workbook) {

  let selectedSheet = workbook.getActiveWorksheet();

  // Auto fit the columns of range A:A on selectedSheet

  selectedSheet.getRange("A:A").getFormat().autofitColumns();

  // Auto fit the columns of range B:B on selectedSheet

  selectedSheet.getRange("B:B").getFormat().autofitColumns();

  // Auto fit the columns of range C:C on selectedSheet

  selectedSheet.getRange("C:C").getFormat().autofitColumns();

  // Auto fit the columns of range D:D on selectedSheet

  selectedSheet.getRange("D:D").getFormat().autofitColumns();

  // Auto fit the columns of range E:E on selectedSheet

  selectedSheet.getRange("E:E").getFormat().autofitColumns();

  // Auto fit the columns of range F:F on selectedSheet

  selectedSheet.getRange("F:F").getFormat().autofitColumns();

  // Set range F4 on selectedSheet

  selectedSheet.getRange("F4").setFormula("=F9");

  // Set range F4:F7 on selectedSheet

  selectedSheet.getRange("F4:F7").setFormulas([["=F9"],["=F16+F23+F40+F64+F70"],["=F4+F5"],["=IF(F4=0,0,(F6/(F4)))"]]);

  // Set range F9 on selectedSheet

  selectedSheet.getRange("F9").setFormula("=SUM(F10:F15)");

  // Set range F16 on selectedSheet

  selectedSheet.getRange("F16").setFormula("=SUM(F17:F22)");

  // Set range F23 on selectedSheet

  selectedSheet.getRange("F23").setFormula("=SUM(F24:F39)");

  // Set range F40 on selectedSheet

  selectedSheet.getRange("F40").setFormula("=SUM(F41:F63)");

  // Set range F64 on selectedSheet

  selectedSheet.getRange("F64").setFormula("=SUM(F65:F69)");

  // Set range F70 on selectedSheet

  selectedSheet.getRange("F70").setFormula("=SUM(F71:F78)");

}

 

Is it possible to do this without getting power automate involved?
And if I have to get power Automate involced do any of you know how big of a task this is?

All help is greatly appreciated.

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@ThomasWeppler , You can check this video it will give some idea

 

https://www.youtube.com/watch?v=v-_joMcPpLI




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

2 REPLIES 2
bhanu_gautam
Super User
Super User

@ThomasWeppler , You can check this video it will give some idea

 

https://www.youtube.com/watch?v=v-_joMcPpLI




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






@bhanu_gautam thanks for the answer.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.