Skip to content

Commit

Permalink
cleanup for defined name
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMarvin committed Aug 22, 2023
1 parent 84698cd commit 5e0cc04
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions R/wb_load.R
Original file line number Diff line number Diff line change
Expand Up @@ -1431,10 +1431,9 @@ wb_load <- function(

val <- sprintf("[%s]%s", xti$ext_id[sel][i], sheetName)


if (any(sel2 <- grepl("\\s", val)))
# non ascii or whitespace
if (any(sel2 <- grepl("[^A-Za-z0-9]", val)))
val[sel2] <- shQuote(val[sel2], type = "sh")
# val <- shQuote(val, type = "sh")

if (length(val)) xti$sheets[sel][i] <- val
}
Expand All @@ -1446,6 +1445,7 @@ wb_load <- function(
if (nrow(xti)) {

if (length(wb$workbook$definedNames)) {

wb$workbook$definedNames <-
stringi::stri_replace_all_fixed(
wb$workbook$definedNames,
Expand Down
6 changes: 6 additions & 0 deletions src/xlsb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,12 @@ int workbook_bin(std::string filePath, std::string outPath, bool debug) {
std::string unusedstring2 = XLNullableWideString(bin, swapit);
}

if (fields->fBuiltin) {
// add the builtin xl name namespace
if (name.find("_xlnm.") == -1)
name = "_xlnm." + name;
}

std::string defNam = "<definedName name=\"" + name;

if (comment.size() > 0)
Expand Down
5 changes: 1 addition & 4 deletions src/xlsb_funs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1302,12 +1302,9 @@ std::string CellParsedFormula(std::istream& sas, bool swapit, bool debug, int co
case PtgArray2:
case PtgArray3:
{
int pre = ptgextra.size();
RgbExtra typ = PtgExtraArray;
ptgextra.push_back(typ);
if (ptgextra.size() <= pre) {
Rcpp::stop("hmm");
}

// ptg_extra_array = true;
uint16_t unused2 = 0;
uint32_t unused1 = 0, unused3 = 0, unused4 = 0;
Expand Down

0 comments on commit 5e0cc04

Please sign in to comment.