Posted: 28 Oct 2018 17:30 EDT Last activity: 17 Feb 2021 10:12 EST
Number of rows in an excel file
I found MicrosoftExcel Connector method, ExportData to read a workbook into .NET data table.Before reading an excel file, I want to count the No of rows in it so I can make some decisions in the automation flow. Is there any out of the box method in pega Robotics that I can use to get the No of rows and columns like in UiPath or do I have to build them on my own?Its handy if we have that method out of the box as well.
With ExportData method of Excel Connector you have to provide End Cell address which is probably not what you know in advance.
1. _Worksheet object has UsedRange property that has Rows property. It returns only rows with some data (or with formatting applied).
2. There is new Excel File Connector (different from Excel Connector) since version 8.0.SP1 2007. You may try to use it's ExportToTable method with 2 parameters and then get count of rows from DataTable object.
In build 8.0 SP1 2010 which is released this week there are additional methods available on the original Excel connector. Use the WorksheetGetUsedRange method to retrieve the row and column count - like this:
This release adds over 40 new methods to the Excel connector.