Skip to content

Commit

Permalink
[xlsb] fix linebreak in formulas (#1247)
Browse files Browse the repository at this point in the history
* [xlsb] fix formulas with linebreaks

* [xlsb] remove invalid definedNames

* [test] fix lintr

* [xlsb] replaceXMLEscapesWithNewline()

* [xlsb] add hsState

* [xlsb] indent xlsb_defines.h
  • Loading branch information
JanMarvin authored Jan 13, 2025
1 parent 4cf7650 commit e6b6914
Show file tree
Hide file tree
Showing 5 changed files with 949 additions and 905 deletions.
6 changes: 6 additions & 0 deletions R/wb_load.R
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,12 @@ wb_load <- function(
}
}

# remove defined names without value. these are not valid and are probably
# remnants of xti
if (length(dfn_nms <- wb$workbook$definedNames)) {
wb$workbook$definedNames <- dfn_nms[xml_value(dfn_nms, "definedName") != ""]
}

# create valid rich text strings in shared strings table
if (any(sel <- grepl("<FONT_\\d+/>", wb$sharedStrings))) {

Expand Down
9 changes: 2 additions & 7 deletions src/xlsb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1606,12 +1606,7 @@ int32_t workbook_bin(std::string filePath, std::string outPath, bool debug) {

std::string val = XLWideString(bin, swapit);

std::string visible;
if (hsState == 0) visible = "visible";
if (hsState == 1) visible = "hidden";
if (hsState == 2) visible = "veryHidden";

out << "<sheet r:id=\"" << rid << "\" state=\"" << visible<< "\" sheetId=\"" << iTabID<< "\" name=\"" << val << "\"/>" << std::endl;
out << "<sheet r:id=\"" << rid << "\" state=\"" << HSState(hsState)<< "\" sheetId=\"" << iTabID<< "\" name=\"" << val << "\"/>" << std::endl;
break;
}

Expand Down Expand Up @@ -3527,7 +3522,7 @@ int32_t worksheet_bin(std::string filePath, bool chartsheet, std::string outPath
if (fields->fHiddenCol)
out << " hiddenColumns=\"" << (int16_t)fields->fHiddenCol << "\"";
if (fields->hsState)
out << " state=\"" << (int16_t)fields->hsState << "\"";
out << " state=\"" << HSState(fields->hsState) << "\"";
if (fields->fFilterUnique)
out << " filterUnique=\"" << (int16_t)fields->fFilterUnique << "\"";
if (fields->fSheetLayoutView)
Expand Down
Loading

0 comments on commit e6b6914

Please sign in to comment.