awalker89 / openxlsx

R package for .xlsx file reading and writing.
Other
363 stars 79 forks source link

conditionalFormatting: "Catastrophic failure" with databar #522

Open Arthfael opened 3 years ago

Arthfael commented 3 years ago

Expected Behavior

Function conditionalFormatting with type = "databar" should format the column as a databar

Actual Behavior

All of the variant calls I have tested corrupt the formatting of the worksheet. When opening the worksheet in Excel, the program reports that it found a problem with the workbook and offers to repair the records. It then reports repairing a catastrophic failure (strangely, at line 15, column 0 - which has nothing to do with the target column). The "databar" formatting of the target column is lost, and in addition all formatting in columns right of the target column disappears.

In addition, the help says that "style" should be length 2 or 3, but if length 3 is used, an error says it should be length 1 or 2.

Steps to Reproduce the Problem

(please attach an example xlsx file if possible)

  1. Create wb with one sheet and write one column of numerical data

    wb <- createWorkbook()
    sheet  <- addWorksheet(wb, "Protein Data")
    writeData(wb, "Protein Data", rep(1, 10))
  2. Function call (all the variants I tested failed): conditionalFormatting(wb, 1, 1, 2:5, type = "databar") # For instance, to apply to only part of the column

  3. Save workbook and open in Excel:

    saveWorkbook(wb, "test.xlsx", TRUE)
    shell("\"test.xlsx\"")

sessionInfo()

shitongbin commented 3 years ago

same +1

ycphs commented 3 years ago

Could you please create this also at ycphs/openxlsx?

I am maintaining the active fork of the package.