ycphs / openxlsx

openxlsx - a fast way to read and write complex xslx files
https://ycphs.github.io/openxlsx/
Other
225 stars 75 forks source link

readWorkbook parameter 'skipEmptyCols' doesn't work as expected #456

Open mingerman311 opened 10 months ago

mingerman311 commented 10 months ago

Describe the bug When reading in cells using readWorkbook() there is a parameter called 'skipEmptyCols'. The default is set to TRUE, but when changed to false the behavior is not what would be expected. Yes, it does now read in empty columns, but it also adds 2 empty columns of NA values.

To Reproduce readWorkbook(workbook, sheet = 'sheet name', rows = 1:46 , cols = 3:16 ) In this case, my column 4 is blank, so this reads in 13 columns (3 to 16, excluding 4)

readWorkbook(workbook, sheet = 'sheet name', rows = 1:46 , cols = 3:16 , skipEmptyCols = F) When this parameter is added, it now reads in 16 columns, because it has the 14 listed, plus the empty 2

Expected behavior When this is run, you would expect a maximum of 14 columns, however you end up with 16 columns because of the two added NA columns in the beginning.

It is important to note that i do NOT have 2 blank columns to the left of these selected columns in my spreadsheet. Columns 1 and 2 have values in them.

Screenshots This photo shows when i do NOT add skipEmptyCols. It skips over my blank column 3 and gives me 13 columns image

This photo is what happens when I add skipEmptyCols = F. 2 phantom columns appear

image