Hello Team,
How do i read an excel file in Init and make it available across all REFramework states?
ThankYou!!
Hello Team,
How do i read an excel file in Init and make it available across all REFramework states?
ThankYou!!
Hi @Bob01
InitAllApplications (Read Excel)
dtExcel → Out Argument → out_dtExcel
|
v
Get Transaction Data / Process Transaction
in_dtExcel = out_dtExcel
2method you can use:
There are two ways to make an Excel file available across all REFramework states:
Read the Excel file in the InitAllApplications workflow into a DataTable and pass it via an out argument from Init, then receive it as an in argument in other states like Get Transaction Data and Process Transaction.
Read the Excel file in Init into a DataTable with project-level scope so it can be accessed directly in all states without using arguments.
Happy Automation
Hi @Bob01
You can read the Excel file anywhere in the Initialization state, but make sure it’s placed after the InitAllSettings.xaml step. In the First Run sequence, add the Workbook Read Range (or any other Excel activity) at the end of the sequence. Then, create a global DataTable variable and assign it as the output of the Read Range activity. Once done, you can use this DataTable variable across all states in the REFramework.
Hope it helps!!
hii @Bob01
Read the Excel file using a read range activity in the Init state, storing the data in a variable like dt_Config with the scope set to Main.
Then pass this variable as an In Argument to the Process.xaml file when you invoke it.
which ensures the data is available during the main processing steps.
Thank you guys for you super quick response & ans
Great @Bob01
Just try both methods, If helpful, mark as solution. Happy automation with UiPath
Hi @Bob01
You can Read the Excel in Init → Store it in a Global Dictionary → Use it in all states.
How to do it (REFramework)
Workbook / Excel → Read Range → store in dtData.
TransactionData(“ExcelData”) = dtData
3.In Process / GetTransactionData / End, simply get it back:
dtData = TransactionData(“ExcelData”)
Cheers
Read the Excel file in Init and save the DataTable as project-level variable i.e global scope.
This allows all workflows (Init, Get Transaction Data, Process, End) to access the DataTable without passing arguments.
Hi @Bob01,
In Init (InitAllSettings.xaml) read the Excel into a DataTable, store it in the Config dictionary, and then retrieve it from Config wherever needed.
Steps:
1. In Init use Excel Application Scope → Read Range → output to a DataTable variable (e.g. dtInput).
2. Add an Assign: Config(“InputDT”) = dtInput
(Config is the existing Dictionary<String,Object> in Main).
3. To use the table later, get it from Config and cast it:
dt = CType(Config(“InputDT”), System.Data.DataTable)
where dt is a DataTable variable in that scope.
4. If you call other workflows, pass the Config dictionary (or the DataTable) as an argument so the invoked workflow can read it.
Team @prashant1603765, @mkankatala Should i create a global data variable in main and avoid arguments
Thanks in advance
Hii, @Bob01
Dont use a global DataTable in Main.
Use the config dictionary. it is correct
Input
like use Config(“inputDt”)=dtInput
then retrieve it from anywhere
dt=Ctype(Config(“Input”, DataTable)
Thanks a lot Team & @manish.pal
Yes, you can create a global variable. That will work if you want to modify the DataTable, as the changes will reflect directly in that variable.
However, if you use the Config variable approach, the data won’t get overwritten, because the Config is used across multiple workflows in In direction.
Hope you understand!!
Yes you can use …
Happy automation
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.