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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Create Excel 97-2003 v...
Power Automate
Unanswered

Create Excel 97-2003 version file based on SQL Query Results without opening the excel actions using power automate desktop

(0) ShareShare
ReportReport
Posted on by 25

General procedure is taking time to generate excel based on SQL Query results if i use launch,Write and save ( taking 15 Secs) and one more issue is after writing into excel and excel is converting text as numeric if query results is alphanumeric but i want the data in excel as it is in query results. 

 

Please help me with below flow.

 

1) Call the cloud flow from desktop using webhook ( Invoke Webservices)

2) Cloud flow should execute the query 

3) Create a excel based on SQL Json 

4) Send response to desktop flow with excel file ( where i can download directly with using the invoke webservices in Desktop flow )

I have the same question (0)
  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @Dg_Reddy 

     

    I understand your use case, but I'm curious about why you're considering the use of a cloud flow when the SQL execute query functionality is already available in the Power Automate Desktop packages. Could you please provide more detail on this matter?

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀. If you'd like to appreciate me, please write a LinkedIn recommendation 🙏

  • Dg_Reddy Profile Picture
    25 on at

    Thanks for ur reply. PAD having all actions to do it but in my situation but I need to prepare the template in less time like 2 secs. earlier i used other tool to prepare a template which is giving the output excel file within 1 sec in my folder.  if u see the below screenshot, Excel Open, Write and save is taking 12 secs and other screenshot is giving less than 1 sec ( using other tool) . But need to remove the dependency on other tools, and replicate the same using power automate. Thanks 

     

    Dg_Reddy_0-1711985169028.png

     

    Dg_Reddy_1-1711985445376.png

     

  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @Dg_Reddy 

     

    Consider using below powershell scripts for the same and fine tune your logic using chatgpt.

    Deenuji_0-1712038559448.png

     

    Powershell Script:

    # Sample JSON input
    $jsonInput = '[
     {"Name": "John", "Age": 30, "City": "New York"},
     {"Name": "Alice", "Age": 25, "City": "Los Angeles"},
     {"Name": "Bob", "Age": 35, "City": "Chicago"}
    ]'
    
    # Convert JSON to PowerShell object
    $data = $jsonInput | ConvertFrom-Json
    
    # Create a new Excel application
    $excel = New-Object -ComObject Excel.Application
    
    # Add a workbook
    $workbook = $excel.Workbooks.Add()
    
    # Get the first worksheet
    $worksheet = $workbook.Worksheets.Item(1)
    
    # Add headers to the first row
    $row = 1
    $col = 1
    foreach ($header in $data[0] | Get-Member -MemberType NoteProperty) {
     $worksheet.Cells.Item($row, $col) = $header.Name
     $col++
    }
    
    # Add data to subsequent rows
    $row++
    foreach ($item in $data) {
     $col = 1
     foreach ($prop in $item.PSObject.Properties) {
     $worksheet.Cells.Item($row, $col) = $prop.Value
     $col++
     }
     $row++
    }
    
    # Save the Excel file in Excel 97-2003 format (.xls)
    $outputFile = "C:\deenu\Exceloutput.xls"
    $workbook.SaveAs($outputFile, 56) # 56 represents the Excel 97-2003 format
    $workbook.Close()
    
    # Quit Excel
    $excel.Quit()
    
    # Clean up
    Remove-Variable -Name excel, workbook, worksheet

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀. If you'd like to appreciate me, please write a LinkedIn recommendation 🙏

  • Dg_Reddy Profile Picture
    25 on at

    Thanks for your response. But still its taking 10 secs to Create the excel file which is higher than power automate desktop. 

  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @Dg_Reddy 

     

    Fascinating! At the end of the day, both PowerShell scripts and Power Automate Desktop perform similar tasks, such as opening the Excel application, creating columns, and saving files. I had the impression that using a script might lead to faster execution times, but it seems I was mistaken.

     

    Are the column headers in this Excel file always the same? If they are, why not consider storing them in a shared drive or SharePoint and downloading them from there?


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard