miraisolutions / xlconnect

XLConnect: Excel Connector for R
129 stars 32 forks source link

Read table by name only #60

Open mjkallen opened 8 years ago

mjkallen commented 8 years ago

The readTable() function in the package requires the sheet index or name to be provided, but table names must be unique in an Excel workbook and thus the XSSFWorkbook Java class in the POI library has a getTable(java.lang.String) method which returns an object of class XSSFTable.

I'm tempted to submit a pull request which adds this feature, but unfortunately the generic function readTable requires a value for the sheet argument to be provided. Making this argument optional would introduce backward incompatibilities, especially since it would be more natural to switch the order of the sheet and table arguments. One solution could be to assume that negative values for sheet indicate that tables should be looked up by their name only.

Any thoughts on this suggestion?

martinstuder commented 8 years ago

Hi @mjkallen,

thanks for getting in touch! I'm open to introduce a backwards-incompatibility for the sake of a cleaner and simpler API. I would be happy to review an appropriate pull request. Before releasing, I would get in touch with the maintainers of packages depending on XLConnect to make sure they have enough time to adapt accordingly.

Let me know what you think.

Thanks & Best regards, Martin

mjkallen commented 8 years ago

Hi Martin,

it turns out that my client doesn't like using tables anyway, because they slow things down too much. So for now there is no pressing need to implement this. One other approach you could use is to add a function which returns the name (or index) of the worksheet which contains the named region (or table). I believe that the POI library has a method for that. You could then use this if the sheet argument is not provided.

Regards,

Maarten-Jan