nacnudus / tidyxl

Read untidy Excel files in R https://nacnudus.github.io/tidyxl/
https://nacnudus.github.io/tidyxl/
Other
246 stars 20 forks source link

select sheet in xlsx_formats() #84

Closed bl6594 closed 2 years ago

bl6594 commented 2 years ago

First of all, thank you very much for the functionality provided in this library, and they are super helpful! Many functions in this library allow the user to specify the tab through the parameter 'sheets'. However, there is no such a parameter in function xlsx_formats(). Is this something hard to do, or have I missed something?

nacnudus commented 2 years ago

The output of xlsx_formats() is a kind of dictionary, where you can look up the format code of a cell, to find out, for example, what colour it is. Excel defines only one of these dictionaries for the whole workbook, so that it records each combination of formats only once. Two cells that have the same formatting, but are in different sheets, will have the same format code, referring to the same entries in that dictionary.

It would be possible to omit entries from the dictionary that aren't used by a particular sheet, but there wouldn't be much point. Tidyxl would still have to read the whole dictionary, and it isn't usually very big. Even the most baroque spreadsheets use only a few thousand different combinations of font, colour, border, fill, gradient, etc.

Are you doing something that would seem to be easier with a list of formats that is specific to a sheet?

bl6594 commented 2 years ago

Thank you for your reply! I now understand that the parameter is not needed in the xlsx_formats().