Every Monday, an HR analyst I worked with opened the same Excel workbook, filtered the salary column, and copied the matching employees into a text file for the payroll team. It took about 20 minutes, and one wrong filter meant a wrong report. We replaced the whole routine with a small Power Automate Desktop flow that reads the worksheet and writes out the rows automatically.
In this tutorial, I’ll show you how to build that flow. First, you’ll extract every row from an Excel worksheet into a text file. Then you’ll extract only the rows that meet a condition, in this case employees who earn more than $80,000.
Quick answer: In Power Automate Desktop, use Launch Excel to open the workbook, then Read from Excel worksheet to load the data into a data table variable called ExcelData. Write it to a file with Write text to file or Write to CSV file. To keep only some rows, loop through ExcelData with For each and an If such as %CurrentItem['Salary (USD)']% > 80000, or use the Filter data table action.
What you need before you start
You need Power Automate Desktop installed on a Windows PC and an Excel workbook saved locally. Keep the workbook in a regular folder such as Downloads or Documents while you build the flow. Excel actions don’t work reliably on files inside a OneDrive or SharePoint sync folder, and they can fail with a file-not-found error there. If your workbook lives in OneDrive, copy it to a local folder first.
For this example, I’m using a workbook named Employee Details. It has six columns: Employee ID, Name, Department, Position, Salary (USD) and Hire Date.

Part 1: Extract all Excel data to a text file
Step 1: Create a desktop flow
Open Power Automate Desktop and select + New flow. Give the flow a clear name, such as Extract Data from Excel File, and select Create. The flow designer opens with an empty workspace.

Step 2: Open the workbook with Launch Excel
In the Actions pane, expand Excel and drag Launch Excel into the workspace. Set Launch Excel to and open the following document, then select the file icon next to Document path and pick your workbook. Make instance visible is on by default, which is handy while you test because you can watch Excel open.

The action creates a variable called ExcelInstance. Every other Excel action in the flow uses it to know which workbook to work with. Select Save.
Step 3: Find where the data ends
You could type a fixed range such as A1 to F21, but that breaks as soon as someone adds a row. It’s better to let the flow find the end of the data. Add Get first free column/row from Excel worksheet. It returns two numbers: FirstFreeColumn and FirstFreeRow, the first completely empty column and row on the active worksheet.

In this workbook, the data fills columns A to F and rows 1 to 21, so the first free column is 7 (G) and the first free row is 22.

Step 4: Read the worksheet into a data table
Add Read from Excel worksheet. Set Retrieve to Values from a range of cells, and fill in the range. Excel actions count rows and columns from 1, so the range starts at column 1 and row 1 and ends one before the free column and row:
- Start column:
1 - Start row:
1 - End column:
%FirstFreeColumn - 1% - End row:
%FirstFreeRow - 1%

Before you save, expand Advanced and turn on First line of range contains column names. This matters later: it keeps the header row out of your data and lets you refer to columns by name, such as Salary (USD). Leave Get cell(s) contents as on Typed values so salaries come through as numbers, not text.
The action stores the result in a data table variable called ExcelData. If you’d rather not work out the range at all, set Retrieve to All available values from worksheet instead; it reads the whole used area of the sheet, and you can skip Step 3.
Step 5: Write the data to a text file
Add Write text to file. Choose the File path of the text file you want to create, put %ExcelData% in Text to write, and keep Append new line on. The file is created if it doesn’t exist.

Save the flow and select Run. Here’s the complete flow:

When it finishes, open the text file. Each row of the worksheet appears on its own line, with the values separated by commas:

If another system will import the file, use Write to CSV file instead. It gives you control over the separator and whether to include the column names, and it writes a proper CSV file that Excel and most databases open cleanly.
Part 2: Extract only the rows that meet a condition
Now for the part the payroll team actually needed: only the employees whose salary is more than $80,000. There are two ways to do it. The loop is easy to understand and debug; the Filter data table action does the same job in a single step.

Option 1: Loop through the rows with For each and If
After the steps in Part 1, add a For each loop and set Value to iterate to %ExcelData%. Each time the loop runs, CurrentItem holds one row of the data table.

Inside the loop, add an If action. Set First operand to %CurrentItem['Salary (USD)']%, Operator to Greater than (>), and Second operand to 80000. The column name has to match the header in the worksheet exactly, and it only works because you turned on First line of range contains column names in Step 4.

Inside the If, add another Write text to file. Point it at a new file, such as Employee Salaries greater than 80000.txt, put %CurrentItem% in Text to write, and set If file exists to Append content, so each matching row is added below the previous one.

Finally, add Close Excel after the loop, with Before closing Excel set to Do not save document. The flow only reads the workbook, so there’s nothing to save.

Run the flow. The new file lists only the employees who earn more than $80,000:

One thing to watch: because the file is set to append, running the flow twice adds the same rows again. Before the loop, add a Write text to file that writes an empty value to the same file with Overwrite existing content, so every run starts with a clean file.
Option 2: Use the Filter data table action
If you don’t need to do anything with each row except keep or drop it, the Filter data table action is simpler. You’ll find it under Variables > Data table. Set the data table to %ExcelData%, add a rule where the column is Salary (USD), the operator is Greater than, and the value is 80000. You can add more rules and combine them with And or Or.
The action produces a new data table called FilteredDataTable with only the matching rows. Save it with Write to CSV file, and you’re done: no loop, no If, and no risk of appending duplicates.
Tips that save debugging time
If the workbook has several sheets, add Set active Excel worksheet right after Launch Excel. Get first free column/row and Read from Excel worksheet both work on the active sheet, and the wrong sheet is the most common reason a flow reads nothing.
If your comparison never matches, check the data type. A salary that was read as text won’t compare correctly with a number. Keep Typed values selected, and make sure the column in Excel is formatted as a number, not text.
Finally, if a narrow column shows ##### in Excel and you read it as formatted text, the flow may read ##### too. Widen the column, or read typed values.
These Power Automate Desktop tutorials build on the same Excel and data table actions:
- Retrieve Excel Column Values Into List Using Power Automate Desktop
- How to Get Values from Data Table using Power Automate Desktop?
- Insert Row into Data Table in Power Automate Desktop
- How to Count Rows & Columns in SpreadSheet by Power Automate Desktop?
- Add Excel Table into HTML Email Body using Power Automate Desktop
- Power Automate Desktop Flow Examples [5 Practical Examples]
Frequently Asked Questions
How do I read an entire Excel sheet in Power Automate Desktop?
Use Launch Excel to open the workbook, then Read from Excel worksheet with Retrieve set to All available values from worksheet. The data is stored in a data table variable, usually ExcelData.
How do I read Excel data with column names in Power Automate Desktop?
In Read from Excel worksheet, expand Advanced and turn on First line of range contains column names. You can then refer to a value as %CurrentItem[‘Column Name’]% inside a For each loop.
How do I extract only some rows from Excel in Power Automate Desktop?
Loop through the data table with For each and an If condition, or use the Filter data table action, which returns only the matching rows in FilteredDataTable.
Why does my desktop flow fail to open an Excel file in OneDrive?
Excel actions don’t work reliably on files in OneDrive or SharePoint sync folders. Copy the file to a local folder first. Microsoft lists this in the known limitations of the Excel actions reference.

I have worked with Microsoft technologies for more than 18 years, including SharePoint, Microsoft 365 and the Power Platform (Power Apps, Power Automate and Power BI), at companies like HP, TCS and KPIT. I started EnjoySharePoint in 2011 to share the solutions I build in real projects with readers in the United States, Canada, the United Kingdom, Australia, New Zealand and beyond. Microsoft has recognized this work with the Microsoft MVP award 13 times since 2014.