Repair warning after exporting data into existing file
My file required repair after exporting from R with saveWorkbook.

Thanks for the report! Do you have a reproducible example of the code that creates such a broken workbook? There are many ways to make this happen if you write a bad record. I.e. in this case, table1.xml seems to have been written badly.
I have the code but the bit that reads the data and metadata into two data.frames data and mt might not be relevant. Just want to say that my output file variable holds the name of the Excel workbook that has tables, power queries.
options(java.parameters = "- Xmx1024m") options(xlsx.date.format = 'dd-mm-yyy')
Pckages <- c('RODBC', 'tidyverse', 'seasonal', 'seasonalview', "lubridate", 'dplyr', 'tidyr', 'purrr', 'zoo', 'xlsx' ) sapply(Pckages, library, character.only = TRUE)
wb<-loadWorkbook(OutputFile) sheets <- getSheets(wb) destSheet <- sheets[["PreVintage"]]
addDataFrame(mt, sheet = destSheet, startRow = 1, characterNA='NA', col.names = FALSE, row.names = TRUE) addDataFrame(as.data.frame(as.Date(rownames(data))), sheet = destSheet, characterNA='NA', startRow = length(metadata_fields)+1, col.names = FALSE, row.names = FALSE) addDataFrame(data, sheet = destSheet, startRow = length(metadata_fields)+1, col.names = FALSE, row.names = FALSE, startColumn = 2)
saveWorkbook(wb, OutputFile)
From: Cole Arendt [mailto:[email protected]] Sent: Tuesday, 18 June 2019 10:59 PM To: colearendt/xlsx [email protected] Cc: ZHANG, Joan [email protected]; Author [email protected] Subject: Re: [colearendt/xlsx] Repair warning after exporting data into existing file (#130)
Thanks for the report! Do you have a reproducible examplehttps://www.jessemaegan.com/post/so-you-ve-been-asked-to-make-a-reprex/ of the code that creates such a broken workbook? There are many ways to make this happen if you write a bad record. I.e. in this case, table1.xml seems to have been written badly.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/colearendt/xlsx/issues/130?email_source=notifications&email_token=AJO3W56LNPURZVOS4WLSFMLP3DLYZA5CNFSM4HY4BAE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX6Q36Q#issuecomment-503123450, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJO3W55OCMYLIGY7EQNDEVDP3DLYZANCNFSM4HY4BAEQ.
This e-mail message (along with any attachments) is intended only for the named addressee and could contain information that is confidential or privileged. If you are not the intended recipient you are notified that any dissemination, copying or use of any of the information is prohibited. Please notify us immediately by return e-mail if you are not the intended recipient and delete all copies of the original message and attachments.
This footnote also confirms that this message has been checked for computer viruses.
Apologies for the late response here. Any chance that you could generate a workbook from scratch that displays this problem? Maybe put the offending characters or data into the code, etc.? You could do so with something like dput() or the datapasta package, perhaps.
It is unfortunately very hard for us to see whether this is a bug in the package if the brokenness could be coming from the OutputFile that you are loading or the data frames that you are adding to the workbook. If you can create a reprex that reproduces the issue without any other state (i.e. data, another workbook that I do not have access to, etc.), that would help tremendously. Thanks!
I have many different objects (e.g. tables, power queries, pivot tables etc.) in the workbook that had the error, hence it took quite a while to eliminate them one by one to find the root cause. It turns out due to the calculated field in a Table. Attached is a test file that would replicate the error.
My code was just writing three data.frames into a sheet different to the one containing the table. Removing the calculated field in the Table stops the warning. Let me know if you can’t reproduce the error.
From: Cole Arendt [mailto:[email protected]] Sent: Thursday, 11 July 2019 9:17 PM To: colearendt/xlsx [email protected] Cc: ZHANG, Joan [email protected]; Author [email protected] Subject: Re: [colearendt/xlsx] Repair warning after exporting data into existing file (#130)
Apologies for the late response here. Any chance that you could generate a workbook from scratch that displays this problem? Maybe put the offending characters into the document, etc.?
It is unfortunately very hard for us to see whether this is a bug in the package if the brokenness could be coming from the OutputFile that you are loading or the data frames that you are adding to the workbook. If you can create a reprexhttps://www.jessemaegan.com/post/so-you-ve-been-asked-to-make-a-reprex/ that reproduces the issue without any other state (i.e. data, another workbook that I do not have access to, etc.), that would help tremendously. Thanks!
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/colearendt/xlsx/issues/130?email_source=notifications&email_token=AJO3W575ODMBFUNIGWIHATLP64JBXA5CNFSM4HY4BAE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZWMDEQ#issuecomment-510443922, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJO3W52IDP4GBVRCH523GYTP64JBXANCNFSM4HY4BAEQ.
This e-mail message (along with any attachments) is intended only for the named addressee and could contain information that is confidential or privileged. If you are not the intended recipient you are notified that any dissemination, copying or use of any of the information is prohibited. Please notify us immediately by return e-mail if you are not the intended recipient and delete all copies of the original message and attachments.
This footnote also confirms that this message has been checked for computer viruses.