How to name/create new tab in excel using uipath? Like I wanted to create a new tab in excel with sample name " Hello world 2020"
and I i add again another string it would be added on the nextline and so on.
I wanted to use excel application scope and wokbook write range.
Firstly, my assumption is that your the excel file or excel sheet is not created yet
- Path Exists to check for excel file that output a boolean variable
- If Boolean variable is false, use activities Excel application scope with Write Range
- Else boolean variable is true, use activities Excel application scope with Append Range
If the assumption above is not true, then you need additional checks.
- Using Excel Application Scope and store the output workbook variable. e.g. TestWB
- Use if activity, checks the workbook variable for the excel sheet. e.g. TestWB.GetSheets(“Sheet 1”)
- If excel sheet is not present then first assumption is applicable
- If excel sheet is present then Range Range activity and store output to DataTable variable. eg. ExcelDT
- Check the number of rows in DataTable variable, e.g. ExcelDT.Rows.Count
- If the rows count is not zero, Append Range
- If rows count is zero, Write Range
Assumption: the excel does not contain used blank/empty rows. It is better to start on a clean excel sheet. Test: press Ctrl + End keys simultaneously on open Excel file to position the active cell on last row, last column.