Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanups in wb_load #538

Merged
merged 3 commits into from
Feb 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions R/wb_load.R
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ wb_load <- function(

## externalLinks
if (!data_only && length(extLinksXML)) {
wb$externalLinks <- lapply(sort(extLinksXML), read_xml, pointer = FALSE)
wb$externalLinks <- lapply(extLinksXML, read_xml, pointer = FALSE)

wb$append(
"Content_Types",
Expand All @@ -613,7 +613,7 @@ wb_load <- function(

## externalLinksRels
if (!data_only && length(extLinksRelsXML)) {
wb$externalLinksRels <- lapply(sort(extLinksRelsXML), read_xml, pointer = FALSE)
wb$externalLinksRels <- lapply(extLinksRelsXML, read_xml, pointer = FALSE)
}


Expand Down Expand Up @@ -841,23 +841,24 @@ wb_load <- function(

for (ws in seq_along(wb$worksheets)) {

# This relships tracks the file numbering. drawing1.xml or comments2.xml
# hyperlinks are not in files, but xml links in the references
wb_rels <- rbindlist(xml_attr(wb$worksheets_rels[[ws]], "Relationship"))
cmmts <- integer()
drwns <- integer()
hlink <- integer()
pvtbl <- integer()
slcrs <- integer()
table <- integer()
trcmt <- integer()
vmldr <- integer()

if (ncol(wb_rels)) {
wb_rels$tid <- as.integer(gsub("\\D+", "", basename(wb_rels$Target)))
# since target can be any hyperlink, we have to expect various things here like uint64
wb_rels$tid <- suppressWarnings(as.integer(gsub("\\D+", "", basename(wb_rels$Target))))
wb_rels$typ <- basename(wb_rels$Type)

cmmts <- wb_rels$tid[wb_rels$typ == "comments"]
drwns <- wb_rels$tid[wb_rels$typ == "drawing"]
hlink <- wb_rels$tid[wb_rels$typ == "hyperlink"]
pvtbl <- wb_rels$tid[wb_rels$typ == "pivotTable"]
slcrs <- wb_rels$tid[wb_rels$typ == "slicer"]
table <- wb_rels$tid[wb_rels$typ == "table"]
Expand All @@ -870,7 +871,6 @@ wb_load <- function(
wb$worksheets[[ws]]$relships <- list(
comments = cmmts,
drawing = drwns,
hyperlink = hlink,
pivotTable = pvtbl,
slicer = slcrs,
table = table,
Expand Down