Read the first sheet of the Read Range Workbook activity

Hello! All good?

I need to use the classic Read Range Workbook activity and I need to read the first sheet of the worksheet, but the name of the worksheet is not fixed, does anyone know an expression where I can get the contents of just the first sheet?
I don’t want to use Excel activities.

Thanks!

@amanda.gondim,

If don’t have excel installed on the system use BalaReva excel workbook activity - Get sheets name, and that returns the array of sheet names, and get the first sheet by myArrVar(0).

If excel is installed then you should be using Excel Process Scope and get the first sheet name. This is the only way.

@amanda.gondim,

Ohh wait, there is one more prebuilt option shared by @ppr here:

You can use below C# code using invoke code activity to get list of sheet names

var FilePath=in_FilePath;
var sheetNames = new List<string>();

using (System.IO.Compression.ZipArchive archive = System.IO.Compression.ZipFile.OpenRead(FilePath))
{
    var entry = archive.GetEntry("xl/workbook.xml");
    if (entry != null)
    {
        using (var reader = XmlReader.Create(entry.Open()))
        {
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "sheet")
                {
                    if (reader.HasAttributes)
                    {
                        string sheetName = reader.GetAttribute("name");
                        sheetNames.Add(sheetName);
                    }
                }
            }
        }
    }
}

out_listSheetNames = sheetNames;

Test.xaml (9.6 KB)

Hi @amanda.gondim

Use the “Get Workbook Sheets” activity to get the sheet names from the Excel file. Then assign the first sheet name to a variable like firstSheet = sheetsList(0). Finally, use the “Read Range Workbook” activity and set the sheet name to firstSheet to read data from the first sheet. This way, you can read the first sheet without using Excel activities.

Happy Automation

Hi @amanda.gondim

Use Get Workbook Sheet activity.

Hope it helps!!

@amanda.gondim

Like this,

If you found helpful, tick as a solution.
Happy Automation