Scenario:Ui path Custom Activity
Steps to reproduce: Working fine in visual studio not working in UIPath
Current Behavior: public class SimpleFormula : CodeActivity
{
[Category("Input")]
[RequiredArgument]
public InArgument<string> PathExcel { get; set; }
[Category("Input")]
[RequiredArgument]
public InArgument<string> SheetName { get; set; }
[Category("Output")]
[RequiredArgument]
public InArgument<DataTable> ResultTable { get; set; }
protected override void Execute(CodeActivityContext context)
{
var ExcelPath = PathExcel.Get(context);
var Sheetname = SheetName.Get(context);
using (OleDbConnection conn = new OleDbConnection())
{
string path = ExcelPath;
string sheetName = Sheetname;
DataTable DtSet = new DataTable();
string Import_FileName = path;
string fileExtension = System.IO.Path.GetExtension(Import_FileName);
if (fileExtension == ".xls")
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Import_FileName + ";" + "Mode=ReadWrite;" + "Extended Properties='Excel 8.0;HDR=YES;'";
if (fileExtension == ".xlsx")
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Import_FileName + ";" + "Mode=ReadWrite;" + "Extended Properties='Excel 12.0 Xml;HDR=YES;'";
using (OleDbCommand comm = new OleDbCommand())
{
comm.CommandText = "Select * from [" + sheetName + "$];";
comm.Connection = conn;
using (OleDbDataAdapter da = new OleDbDataAdapter())
{
da.SelectCommand = comm;
da.Fill(DtSet);
}
}
var result = DtSet;
ResultTable.Set(context, result);
}
}
}
Expected Behavior:Read the data from DataTable
Studio/Robot/Orchestrator Version:
Last stable behavior:
Last stable version:
OS Version:
Others if Relevant: (workflow, logs, .net version, service pack, etc):