openxlsx2 icon indicating copy to clipboard operation
openxlsx2 copied to clipboard

MIP sensitivity labels don't appear to save

Open PD-LUHC opened this issue 5 months ago • 8 comments

Having followed the thread of issues starting at https://github.com/ycphs/openxlsx/issues/461 and ending at https://github.com/JanMarvin/openxlsx2/pull/983 I have had limited success in getting MIP labels to successfully apply to files saved using wb_save. Possibly I'm being dim, but I don't see why the simplified, example below shouldn't work:

xlsx_path <- "~/simple_test2.xlsx" # desired output path
wb_w_mips <- wb_load("~/mip_template.xlsx") # existing xlsx with correct mip label
mip_xml <- wb_get_mips(wb_w_mips) # also tested this by manually extracting LabelInfo.xml and pasting string in here - no joy.

wb <- wb_workbook() |>
    wb_add_worksheet() |> 
    wb_add_mips(xml = mip_xml) |>
    wb_save(file = xlsx_path, overwrite = TRUE) # this saves a file with no mip label set

if (interactive()) wb$open() # this opens a temp file with mip label set

Interestingly saving the file does not appear to apply the label. But using open() launches a temp file with the label applied. Is it just me or is that unintuitive? What is it about saving a fresh file that prevents the mip label being applied? image image

This is running on openxlsx2 1.9

PD-LUHC avatar Sep 25 '24 09:09 PD-LUHC