Is there a way to import excel tables by only specifying the table's name?

I use a lot of excel tables in a single sheet that are constantly changing size and sometimes even position or maybe even sheets.
It would be great to be able to write the table's name (which has to be unique per excel file) in the range argument of readxl::read_excel().
This would make the whole process more dynamic without worrying if read_excel is picking up stuff that it shouldn't.
But I'll take any solution that can help me with this problem.

I think read_excel only read each sheet as a dataframe.

You may be able to select region in each sheet.

But as you said the region is changing. So I do not think there is a quite solution for it.

You may want to look into tidycells which claims to Read Tabular Data from Diverse Sources and Easily Make Them Tidy.

Interesting package for untidy data but it doesn't accept an excel table as an argument which is very tidy by nature.
It is quite disappointing that I cannot find a package that is able to do this :confused:
Since Excel tables are great for several reasons:
All columns have automatically the same number of rows, it can be created either manually, via Power Query or via a DAX Query and are dynamic i.e. they expand automatically as new data is created. And last but not least it has an unique name per excel file thus it uniquely identifies the range.
So I am really surprised that I cannot find an R package that simply accepts the table's name.

openxlsx seems be able to read from a named region in read.xlsx and namedRegion argument

See ?getNamedRegions() too.

Does table's name and named region the same ? If so, it should work. I let you try.

And FWIW, there is a feature request still open in readxl

Hi, no. A named range is not the same as an excel table :confused:
This is my current work around, to create some dynamic named ranges but this is not ideal. Thanks.

1 Like