Closed christianbraathen closed 2 years ago
Hi @christianbraathen , could you please provide an example file. You can attach it to the github issue (it was already requested in the issue template you choose to ignore). Thanks
Hi! Sorry for the late reply here. I discovered the solution, so I'll just give it to you outright. If you still want me to modify by filling out the template and providing an example file, just let me know.
However, the solution is actually ridiculously simple: Adding the sheet name to the cell references that are made within the same sheet as the formula. In ordinary Excel, writing in Sheet 1, it would normally be sufficient to write—for example—=A1
in cell B1
. However, 'Sheet 1'!$A$1
is needed in B1
to avoid corrupted files in Excel for Mac.
Please note I have tried both with/without absolute references—they can be skipped. So both 'Sheet 1'!$A$1
and 'Sheet 1'!A1
produces a non-corrupt file.
So I would recommend that you modify writeFormula
(and writeData
if input is of class formula
) to check if the reference is missing the sheet name, and to automatically prepend it if is. Alternatively, just write in the documentation that it is recommended to use sheet names in references to avoid corrupted files for Mac users.
Let me know if you need more from me. And thumbs up for an awesome package!
Great that you found a solution! I merely requested an R example, some code to understand what you did or want to achieve. Something minimal like
wb <- createWorkbook()
addWorksheet()
writeData()
... # something that causes the corruption
saveWorkbook ()
Right now I simply got that you have an issue an found a solution. But no worries, if you've solved the issue you can simply close the issue.
I realize now that the error was actually something quite different. It is simply that all formulas must follow the syntax of using commas as argument separators. So there is no need to use the sheet references unless the data occurs in other sheets. Demonstrated within the sheet Bar
:
INDEX(Foo!A:A; MATCH(Bar!$A$1; Foo!B:B; 0))
fails because of semicolon-separated arguments.INDEX(Foo!A:A; MATCH($A$1; Foo!B:B; 0))
fails because of semicolon-separated arguments.INDEX(Foo!A:A, MATCH(Bar!$A$1, Foo!B:B, 0))
works because of comma-separated arguments.INDEX(Foo!A:A, MATCH($A$1, Foo!B:B, 0))
works because of comma-separated arguments.So @ycphs , there's a need to update the documentation of writeFormula
, specifying that the arguments must be comma-separated.
PR here: #322
loadWorkbook
command. This file consists of one sheet, and this sheet has one cell that uses a dropdown list. This dropdown list has two choices: Yes and No.addWorksheet
andwriteData
.saveWorkbook
.