ycphs / openxlsx

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

freezePane(firstActiveRow, firstActiveCol) not working as expected #460

Open gabrielwolfson opened 6 months ago

gabrielwolfson commented 6 months ago

Describe the bug When freezing excel rows and columns, the user must either specify 'firstRow = TRUE' and 'firstCol = TRUE' or provide 'firstActiveRow' and 'firstActiveCol' arguments. When using 'firstRow = TRUE' combined with 'firstActiveCol' or 'firstActiveRow' combined with 'firstCol = TRUE', the 'firstActive_x' argument is ignored.

To Reproduce df <- mtcars

wb <- createWorkbook()

addWorksheet(wb = wb, sheetName = "Sheet 1")

writeData(wb = wb, sheet = "Sheet 1", x = df)

works:

example 1: firstRow = TRUE, firstCol = TRUE

freezePane(wb = wb, sheet = "Sheet 1", firstRow = TRUE, firstCol = TRUE)

openXL(file = wb)

example 2: firstActiveRow = 3, firstActiveCol = 4

freezePane(wb = wb, sheet = "Sheet 1", firstActiveCol = 4, firstActiveRow = 3)

openXL(file = wb)

does not work:

example 3: firstRow = TRUE, firstActiveCol = 4

freezePane(wb = wb, sheet = "Sheet 1", firstRow = TRUE, firstActiveCol = 4)

openXL(file = wb) #firstActiveCol does not freeze cols

example 4: firstActiveRow = 3, firstCol = TRUE

freezePane(wb = wb, sheet = "Sheet 1", firstActiveRow = 3, firstCol = TRUE)

openXL(file = wb) #firstActiveRow does not freeze rows

Expected behavior In example 3: first row and columns 1-3 should be frozen (only first row is frozen) in example 4: first column and rows 1-2 should be frozen (only first column is frozen)

Example files example_1.xlsx example_2.xlsx example_3.xlsx example_4.xlsx

Additional context Given the easy workaround, it's not critical that this be addressed on the back-end. It might be simpler to include a note in the documentation.