Open PD-LUHC opened 2 days ago
Hi @PD-LUHC , your code looks valid and I’m not sure what happens. The difference between wb$open()
and wb$save()
should be that the first writes a file to tempdir and opens it and the latter simply saves the file.
As stated before, I have no way to test this. I can look into it sometime next week, but unless something strikes my eye …
Can you save the file to your desktop and open it with xl_open()
just to make sure that there isn’t something else going on with your directory.
Another idea. Could you try the chained code? In case that there’s something going wrong in the wrapper code.
wb$save(xlsx_path)
wb_load(xlsx_path)$get_mips()
Please check this as well, to see if the mips string is found in the file.
Hi @JanMarvin, thanks for you swift reply and helpful suggestions. FYI, I have a small update - because I was worried I might be doing something silly, I copied your example from here https://github.com/JanMarvin/openxlsx2/pull/983#issue-2215472480 and made two changes:
wb_save
line pointing to the same folder that the reference file was stored inAll the intermediate validation from your example returned TRUE
, but it still replicated the behaviour of my initial post.
Either way, thanks for your time. I'll definitely give your suggestions a whirl and report back when I can.
Hm, you could save the file that works fine via excel and inspect if there’s something going on. (Unzip and compare the xml files line by line). If you fancy you could send me both files. Otherwise I can look into the issue next week, but no promises. I can only guess if it works and if it doesn’t, excel won’t tell me.
These mips strings are basically xml stamps like „confidential“ that only appear in environments that have (maybe this specific) mips setting enabled and Microsoft believes that this is something only businesses can have.
Here is save (and a couple of lines more) https://github.com/JanMarvin/openxlsx2/blob/b3f915054625c5314ee028a479443062ea1ec712/R/class-workbook.R#L2864
And wb_open uses xl_open https://github.com/JanMarvin/openxlsx2/blob/b3f915054625c5314ee028a479443062ea1ec712/R/xl_open.R#L49
Simply saving the file and opening the workbook.
Hm, you could save the file that works fine via excel and inspect if there’s something going on. (Unzip and compare the xml files line by line). If you fancy you could send me both files. Otherwise I can look into the issue next week, but no promises. I can only guess if it works and if it doesn’t, excel won’t tell me.
These mips strings are basically xml stamps like „confidential“ that only appear in environments that have (maybe this specific) mips setting enabled and Microsoft believes that this is something only businesses can have.
Yeah I think there is some corporate voodoo going on with mips. I had a look through the xml files of the two xlsx and found references to LabelInfo.xml in 2 other files (.rels and [Content_Types].xml). I found no major differences (some of the entries had a different ordering, but the entries were the same).
Interestingly I zipped the files back up and opened in excel to find that both were now showing as having no label applied. So the act of unzipping and zipping was enough to disrupt the reading/application of the label. For completeness, unzipping the re-zipped file showed exactly the same contents and get_mips()
returns the expected value
So beyond setting the right label xml, I think maybe there is some other process/rule that is determining how LabelInfo is being read and applied.
Corporate voodoo.
What bothers me, though. That it works for one file and not for the other.
I just don’t see why one fails and the other works.
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: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?This is running on openxlsx2 1.9