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 to fix Excel sprea...
Power Automate
Answered

How to fix Excel spreadsheet skipping rows when pasting data

(0) ShareShare
ReportReport
Posted on by 16

I'm working on a basic flow to parse custom data from pdf invoices onto a spreadsheet. The flow is 90% complete but run into an issue. The steps of my flow are:

 

1. find folder containing PDFs
2. parse text from PDFs and store as variables
3. get first free row on Excel column
4. write variables to Excel column
5. Restart loops until all PDF is scanned

 

Here's what my flow looks like:

Screenshot 2024-04-01 145308.png

Here's the output of my flow:

Screenshot 2024-04-02 130214.png

I am trying to avoid skipping one row every time a new row is inserted. How should I approach this? Any help is appreciated!

  • sergiopereira83 Profile Picture
    25 on at

    You are inserting a list into the cell. Doesn't this list have a blank line below?

     

    And one question, how are you inserting data into different columns using the same list variable?

  • RPA_Noob Profile Picture
    16 on at

    The data are parsed directly from PDF files, so no blank lines really. The flow actually extends beyond the picture taken, so there are other variables before the loop concludes. 

  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @RPA_Noob ,

     

    I have tried to replicate you flow not exactly same. Just take this as reference and create.

    You have used Get first free row on column from excel worksheet action instead use Get First Free Column\Row from Excel Worksheet action.

     

    You have created the flow on Power FX enabled please disable the Power Fx and Try to create or copy the code to your flow and make necessary changes.

     

    VishnuReddy1997_1-1712104133835.png

     

     

    Code:

     

    Folder.GetFiles Folder: $'''C:\\Users\\OneDrive\\Desktop\\Required Documents''' FileFilter: $'''*pdf''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> Files
    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Users\\Desktop\\Practice\\Database\\Invoices.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
    LOOP FOREACH CurrentItem IN Files
    Pdf.ExtractTextFromPDF.ExtractText PDFFile: CurrentItem.FullName DetectLayout: False ExtractedText=> ExtractedPDFText
    Text.ParseText.RegexParseForFirstOccurrence Text: ExtractedPDFText TextToFind: $'''Start date.*\\n.*''' StartingPosition: 0 IgnoreCase: False OccurrencePosition=> Position Match=> Match
    Excel.GetFirstFreeColumnRow Instance: ExcelInstance FirstFreeColumn=> FirstFreeColumn FirstFreeRow=> FirstFreeRow
    Excel.WriteToExcel.WriteCell Instance: ExcelInstance Value: Match Column: $'''A''' Row: FirstFreeRow
    END
    Excel.CloseExcel.CloseAndSaveAs Instance: ExcelInstance DocumentFormat: Excel.ExcelFormat.FromExtension DocumentPath: $'''C:\\Users\\OneDrive\\Desktop\\Power Automate Desktop\\Copy of Invoices.xlsx'''

     

    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    Vishnu Reddy

     

     

     

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    Hi @RPA_Noob,

    Greetings for the day!!

     

    I've examined the code from your screenshot, and overall, it appears fine to me. However, there's one aspect that requires some scrutiny.

     

    During debugging, please ensure to verify whether the variable, after splitting, contains any blank data in the first row of your claimant variable like below. 

     

    Deenuji_0-1712113476306.png

    If that's the case, you can use replace action instead of split to replace your "Claimant" with empty string or  directly reference the claimant index number as like below yellow highlighted power fx syntax (Power Fx Index starts with 1 and not with 0) when writing the data into your Excel file . This approach should resolve the issues you're encountering.

    Deenuji_2-1712114188447.png

     

    Furthermore, we can adjust the regex to trim any leading or trailing spaces during the split function. You can try this approach if possible.

     

    Another option is to remove blank rows from the list, but please note that Power Fx-enabled flows currently do not support this functionality as it is still in the preview stage.

     

    Finally, since Power Fx is still in the preview stage, I would not recommend using it for any real-time projects at the moment, as there are many challenging scenarios with variable manipulation. If you want to disable Power Fx, simply keep it disabled when creating your flow, as shown in the screenshot below.

    Deenuji_3-1712114502335.png

     


    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 🚀

     

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Instead of using Split text, use Replace text to replace "Claimant:" with an empty string (using =""):

    Agnius_0-1712117494453.png

     

    This will prevent your Claimant variable from becoming a list with an empty value in the beginning. Do the same with other values, as I assume you're using Split text there, too.

  • RPA_Noob Profile Picture
    16 on at

    Thank you! That was so simple, I feel annoyed for not figuring it out sooner. With the replace action, the text is replaced with an empty space instead. Is there any way to replace with no value at all?

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 414

#2
11manish Profile Picture

11manish 335 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard