Hi,
How can I open excel file and leave only headers which are at first row? Which activities can I use to delete all rows except headers?
Hi,
How can I open excel file and leave only headers which are at first row? Which activities can I use to delete all rows except headers?
Use Excel Application Scope to open the Excel file.
From there, do a Read Range on the entire sheet, with the Output to variable âmysheetâ.
Then use the Delete Range activity, set the Range property to âA2:Zâ & mysheet.Rows.Count. This will delete everything after row 1 within columns A through Z.
You can change Column Z of course if your data goes beyond that.
Not sure this will work, but try read the sheet into a data table (with headers) and then use clear datatable, then write dt (with headers) back to excel file.
One easy and fast way would be to use Invoke VBA activity with this little code:
Sub DeleteExceptFirst()
Rows("2:" & Rows.Count).ClearContents
End Sub
I see you posted invoking VBA code a couple times recently. Could you share an sample image of the activity in UiPath and specify if it belongs inside a scope activity, etc.? Thanks in advance.
and that code go inside that script.vba
file.
@bcorrea
Hi,
Thank you for your response!
I created process as you advised, but when robot use Excel Application Scope activity Excel file opens and showing message:
After it robots stops with this error:
@amanda.smith
Thank you for your response!
I created that process, but in âDelete rangeâ activity in âInputâ section:
there is Error: âRowsâ is not part of âUiPath.Excel.WorkbookApplicationâ
@bcorrea
it will not help, because excel files are store in shared folder and each time excel file will be new.
How strange. Iâve been using those same steps for a couple processes Iâve been running. Do you know if your Excel package has been updated?
You have the option of setting that in trust center for all filesâŚ
do you see any message when navigating to â!â sign?
Sorry yes, I pulled this from the process Iâm currently building and I donât have that activity connected yet. In looking at the last one I completed, it looks like you just need to add .ToString to the end of it.
@amanda.smith
Seems âRowsâ belongs to Datatable. Do you indicate DataTable in âReadRangeâ activity?
@amanda.smith
I created a process a bit in another way. The flow is:
âExcel Application Scopeâ â âRead rangeâ indicating âOutputâ to Datatable â âAssignâ Variable: ExcelRows=MyDataTableName.Rows.Count â âDelete rangeâ indicating in Range field:âA2:Zâ & ExcelRows.ToString
and it worked!
HI @Apple1,
Here is the solutionâŚ
input :
Output :
Workflow design:
Sample Project :
DeleteData.zip (50.5 KB)
Regards
Balamurugan.s
here all rows deleted? from A2?
@MitheshBolla In these kind of situations if you are trying to keep a header as a template, then better to keep a template file which can be reused in all the execution. Deleting the rows can take sometime based on the number of rows.