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

combined version of xlcCall + Attributes with deduplication #208

Closed
wants to merge 72 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
d2febb7
tinytex and necessary packages in devcontainer
spoltier Jan 16, 2024
d8b18c0
Dockerfile - more TeX packages needed for vignettes
spoltier Jan 16, 2024
3952ad8
R in vscode comes with lintr, disabling for now
spoltier Jan 17, 2024
72bf056
run args for using podman in local devcontainers
spoltier Jan 17, 2024
116982e
issue #37: add worksheetName with 'null' default
spoltier Mar 21, 2019
9abc9ab
WIP troubleshooting java xlcall method
spoltier May 27, 2019
50b112d
poi 4.1.0 update dependency jars
spoltier Jun 7, 2019
2f40a57
Updated XLConnect jar
spoltier Jun 27, 2019
b9ec9e1
POI 4.1.0 remove jar in wrong location
spoltier Jun 27, 2019
5ec0173
POI 4.1.0 - java changes recommended in review
spoltier Jul 11, 2019
f24ecaf
POI 4.1.0: released xlconnect java
spoltier Aug 22, 2019
55e6f54
#37: fix tests, use XLConnect java 1.0.0 + changes
spoltier Sep 5, 2019
c52ac8a
#37 updated xlconnect java
spoltier Sep 11, 2019
f0ea5c4
#37: clean up code, add test case
spoltier Sep 11, 2019
bd23324
#37 add negative test case
spoltier Sep 11, 2019
36c7ae6
#37 documentation
spoltier Sep 11, 2019
e50856d
#37 fix doc of readNamedRegion
spoltier Sep 11, 2019
b46d2c3
gh #37: write in specific sheet's named region
spoltier Sep 19, 2019
bc4c8f9
gh #37: create, check existence, and append to named region + tests
spoltier Sep 19, 2019
338800d
gh #37 clearNamedRegion of specified worksheet
spoltier Sep 26, 2019
ed430f0
gh #37: add clear Named region test with worksheet name
spoltier Sep 26, 2019
c6f3b4f
#37 create name: set worksheet if name provided
spoltier Oct 2, 2019
f0f213e
gh #37: sync jar, dev version
spoltier Aug 19, 2021
abd0b45
#37 add and clean up doc
spoltier Aug 19, 2021
93ffd3e
gh#37 test: formula sheet vs scope sheet
spoltier Sep 16, 2021
2fa5869
gh#37 fix scope v formula - sheet property in java
spoltier Sep 16, 2021
b0e9835
#37 fix clearNamedRegion (java), cleanup, clearer doc
spoltier Sep 16, 2021
476c7f3
gh#37: remove jcenter, seems down
spoltier Sep 16, 2021
c8657e7
gh #37: test cloning names
spoltier Sep 16, 2021
9bf9146
#37 fix cloning names (java)
spoltier Sep 16, 2021
f5b2c3c
#37 match worksheet name strictly (Java)
spoltier Sep 16, 2021
1ad9fae
gh#37 adapt doc to strict matching
spoltier Sep 16, 2021
511b6f4
#37 correct null check in readNamed...
spoltier Sep 16, 2021
e701c21
Review: null handling / default value
spoltier Sep 23, 2021
9fa0420
Review: parameter name change to '...scope'
spoltier Sep 23, 2021
d77dae0
Review: write Named region - WIP?
spoltier Sep 23, 2021
b69998f
Review: write Named region - doc
spoltier Sep 23, 2021
b34b15f
Review: use "" for explicit global scope
spoltier Sep 23, 2021
886dce2
Fix doc syntax
spoltier Sep 23, 2021
e68f020
Review: worksheet scope for ref coordinates + doc fixes
spoltier Sep 23, 2021
43b2827
Review: scoped removeName, doc fix
spoltier Sep 23, 2021
b8fa8de
Review: scoped addImage, missing default
spoltier Sep 23, 2021
34dc05b
Review - fix doc
spoltier Sep 23, 2021
758ade9
Review: addImage backwards compat
spoltier Sep 27, 2021
b2608d1
addImage fix doc
spoltier Sep 27, 2021
6dbcd55
review: dimension-abiding readNamedRegion
spoltier Oct 7, 2021
cd6959f
Restore full clear named region check
spoltier Oct 7, 2021
0155ba9
Test write named to file with scope vector
spoltier Oct 7, 2021
770a4ee
Proposed fix, test change, fix read test
spoltier Oct 7, 2021
9e378f8
Fixed test
spoltier Oct 14, 2021
d50fd60
attributes (handling new java cls, setting attrs)
spoltier Oct 14, 2021
0390b4d
processing attributes, working for n scopes
spoltier Oct 14, 2021
e374069
jar - handle null scope in create
spoltier Oct 21, 2021
60131ac
Adapted attribute handling with suggested approach
spoltier Oct 21, 2021
28b9e01
correctly set names
spoltier Oct 21, 2021
1a5718e
clean up, ws scope attribute when null (jar)
spoltier Oct 28, 2021
58d7ec2
WIP read named region attributes
spoltier Oct 28, 2021
e8c55d6
note after discussing with Riccardo
spoltier Oct 28, 2021
0b6c093
attribute value is array of string
spoltier Oct 28, 2021
2e7d153
Attributes in dataframe from java
spoltier Oct 28, 2021
dbbb117
preserve attributes in extractRowNames
spoltier Nov 11, 2021
de8fe3d
use xlconnect-java rebased - with `overwriteFormulaCells`
spoltier Jan 10, 2024
c65a0c1
Jar from rebased XLConnect-java (refactoring)
spoltier Jan 17, 2024
055dcc6
comment at end of existing line to avoid lintr complaining
spoltier Jan 17, 2024
34349e8
exclude all R code locations in lintr
spoltier Jan 17, 2024
93fc50a
align xlcWithAttr... with changes to xlcCall
spoltier Jan 23, 2024
a4bdccf
avoid overwriting names when setting attributes
spoltier Jan 23, 2024
6af0efd
checkTrue instead of checkExists for bool with attributes
spoltier Jan 23, 2024
12d4148
test write named region using (supported) scalar formula values only
spoltier Jan 23, 2024
3bab24a
Doc: fix argument order in writeNamedRegionToFile
spoltier Jan 23, 2024
d603da9
combined version of xlcCall + Attributes with deduplication
spoltier Jan 23, 2024
531ccd8
.withAttributes: align doc
spoltier Jan 23, 2024
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
13 changes: 12 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,15 @@ RUN apt-get install -y libqpdf28 qpdf ghostscript
RUN install2.r --error devtools rJava RUnit zoo qpdf languageserver
RUN installGithub.r r-lib/revdepcheck
RUN apt-get install -y pandoc
RUN install2.r --error ggplot2
RUN install2.r --error ggplot2 tinytex
RUN Rscript -e "{\
library(tinytex);\
tlmgr_install('datetime');\
tlmgr_install('inputenc');\
tlmgr_install('hyperref');\
tlmgr_install('url');\
tlmgr_install('fmtcount');\
tlmgr_install('float');\
tlmgr_install('natbib');\
tinytex:::install_yihui_pkgs();\
}"
20 changes: 13 additions & 7 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"customizations": {
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"eamodio.gitlens",
"REditorSupport.r",
"github.vscode-pull-request-github",
"github.vscode-github-actions"
]
}
"extensions": [
"eamodio.gitlens",
"REditorSupport.r",
"github.vscode-pull-request-github",
"github.vscode-github-actions"
]
}
}

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
Expand All @@ -28,4 +28,10 @@

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "vscode"

// The below may help when using podman instead of docker as the container backend
// (see https://github.com/microsoft/vscode-remote-release/issues/7175#issuecomment-1645498699)
// ,"runArgs": [
// "--log-driver=none"
// ]
}
2 changes: 0 additions & 2 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
r-version: oldrel
java: 17 #8
vignettes: true
xlc-repo: https://jcenter.bintray.com
timezone-name: Europe/Zurich
- os-name: ubuntu # windows-2019, macos-10.15]
os-version: latest
Expand All @@ -44,7 +43,6 @@ jobs:
r-version: devel
java: 17
vignettes: true
xlc-repo: https://jcenter.bintray.com
timezone-name: Pacific/Marquesas
- os-name: macos # TODO fix java / R interaction
os-version: latest
Expand Down
3 changes: 3 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
linters: linters_with_defaults() # see vignette("lintr")
encoding: "UTF-8"
exclusions: list("R", "demo", "inst", "tests") # disables linting with lintr, as we have not decided yet which linters to use
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: XLConnect
Type: Package
Title: Excel Connector for R
Version: 1.0.8.9999
Version: 1.1.0.9999
Authors@R: c(person("Mirai Solutions GmbH", role = "aut",
email = "[email protected]"),
person("Martin", "Studer", role = "cre",
Expand Down
8 changes: 6 additions & 2 deletions R/dataframeFromJava.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@ dataframeFromJava <- function(df, check.names) {
res[[i]] = v
}

# Apply attributes
toSet = (attributes(df))[!names(attributes(df)) %in% c("jobj", "jclass", "class", "package")]
# Apply names
names(res) = columnNames
attributes(res) = toSet
names(res) = columnNames
result = data.frame(res, check.names = check.names, stringsAsFactors = FALSE)

data.frame(res, check.names = check.names, stringsAsFactors = FALSE)
result
})
}
5 changes: 4 additions & 1 deletion R/extractRownames.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
extractRownames <- function(x, col) {
if(is(x, "list")) {
if(is.null(col)) col = list(NULL)
mapply(extractRownames, x, col, SIMPLIFY = FALSE)
res <- mapply(extractRownames, x, col, SIMPLIFY = FALSE)
attributes(res) <- attributes(x)
res

} else{
# use attr(x, "row.names") instead of row.names or rownames
# since row.names coerces to character for backward compatibility
Expand Down
43 changes: 43 additions & 0 deletions R/withAttributesFromJava.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#############################################################################
#
# XLConnect
# Copyright (C) 2010-2021 Mirai Solutions GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
#############################################################################

#############################################################################
#
# Utility function for converting XLConnect java objects with added attributes
# to R variables with the corresponding attributes.
#
# Author: Simon Poltier, Mirai Solutions GmbH
#
#############################################################################

withAttributesFromJava <- function(jobj) {

# jni <- .jcall(jobj, "S", "jni")
# unwrapped <- .jcall(jobj, jni, "getValue")
unwrapped <- jobj$getValue()

allANames = .jcall(jobj, "[S", "getAttributeNames")
# allAValues = .jcall(jobj, "[S", "getAttributeValues")

for(i in seq(along = allANames)) {
attr(unwrapped, allANames[i]) <- jobj$getAttributeValue(allANames[i])
}
unwrapped
}
12 changes: 6 additions & 6 deletions R/workbook.addImage.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
#
#############################################################################

setGeneric("addImage",
function(object, filename, name, originalSize = FALSE) standardGeneric("addImage"))
setGeneric("addImage",
function(object, filename, name, originalSize = FALSE, worksheetScope = NULL) standardGeneric("addImage"))

setMethod("addImage",
signature(object = "workbook"),
function(object, filename, name, originalSize = FALSE) {
xlcCall(object, "addImage", filename, name, originalSize)
setMethod("addImage",
signature(object = "workbook"),
function(object, filename, name, originalSize = FALSE, worksheetScope = NULL) {
xlcCall(object, "addImage", filename, name, originalSize, worksheetScope %||% .jnull())
invisible()
}
)
6 changes: 3 additions & 3 deletions R/workbook.appendNamedRegion.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@

setGeneric("appendNamedRegion",
function(object, data, name, header = FALSE, overwriteFormulaCells = TRUE,
rownames = NULL) standardGeneric("appendNamedRegion"))
rownames = NULL, worksheetScope = NULL) standardGeneric("appendNamedRegion"))

setMethod("appendNamedRegion",
signature(object = "workbook", data = "ANY"),
function(object, data, name, header = FALSE, overwriteFormulaCells = TRUE,
rownames = NULL) {
rownames = NULL, worksheetScope = NULL) {
if(is.character(rownames))
data <- includeRownames(data, rownames)
# pass data.frame's to Java - construct RDataFrameWrapper Java object references
data <- lapply(wrapList(data), dataframeToJava)
xlcCall(object, "appendNamedRegion", data, name, header, overwriteFormulaCells, .simplify = FALSE)
xlcCall(object, "appendNamedRegion", data, name, worksheetScope %||% .jnull(), header, overwriteFormulaCells, .simplify = FALSE)
invisible()
}
)
76 changes: 38 additions & 38 deletions R/workbook.clearNamedRegion.R
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
#############################################################################
#
# XLConnect
# Copyright (C) 2010-2024 Mirai Solutions GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
#############################################################################
#############################################################################
#
# Clearing a named region
#
# Author: Nicola Lambiase, Mirai Solutions GmbH
#
#############################################################################
setGeneric("clearNamedRegion",
function(object, name) standardGeneric("clearNamedRegion"))
setMethod("clearNamedRegion",
signature(object = "workbook", name = "character"),
function(object, name) {
xlcCall(object, "clearNamedRegion", name)
invisible()
}
)
#############################################################################
#
# XLConnect
# Copyright (C) 2010-2024 Mirai Solutions GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
#############################################################################

#############################################################################
#
# Clearing a named region
#
# Author: Nicola Lambiase, Mirai Solutions GmbH
#
#############################################################################

setGeneric("clearNamedRegion",
function(object, name, worksheetScope = NULL) standardGeneric("clearNamedRegion"))

setMethod("clearNamedRegion",
signature(object = "workbook", name = "character"),
function(object, name, worksheetScope = NULL) {
xlcCall(object, "clearNamedRegion", name, worksheetScope %||% .jnull(), .simplify = FALSE)
invisible()
}
)
1 change: 1 addition & 0 deletions R/workbook.cloneSheet.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
setGeneric("cloneSheet",
function(object, sheet, name) standardGeneric("cloneSheet"))

# TODO make cloning names optional
setMethod("cloneSheet",
signature(object = "workbook", sheet = "numeric"),
function(object, sheet, name) {
Expand Down
76 changes: 38 additions & 38 deletions R/workbook.createName.R
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
#############################################################################
#
# XLConnect
# Copyright (C) 2010-2024 Mirai Solutions GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
#############################################################################
#############################################################################
#
# Creating names in a workbook
#
# Author: Martin Studer, Mirai Solutions GmbH
#
#############################################################################
setGeneric("createName",
function(object, name, formula, overwrite = FALSE) standardGeneric("createName"))
setMethod("createName",
signature(object = "workbook"),
function(object, name, formula, overwrite = FALSE) {
xlcCall(object, "createName", name, formula, overwrite)
invisible()
}
)
#############################################################################
#
# XLConnect
# Copyright (C) 2010-2024 Mirai Solutions GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
#############################################################################

#############################################################################
#
# Creating names in a workbook
#
# Author: Martin Studer, Mirai Solutions GmbH
#
#############################################################################

setGeneric("createName",
function(object, name, formula, overwrite = FALSE, worksheetScope = NULL) standardGeneric("createName"))

setMethod("createName",
signature(object = "workbook"),
function(object, name, formula, overwrite = FALSE, worksheetScope = NULL) {
xlcCall(object, "createName", name, worksheetScope %||% .jnull(), formula, overwrite)
invisible()
}
)
Loading
Loading