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

Feature/#37 named by sheet #216

Merged
merged 101 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
9f88a1b
issue #37: add worksheetName with 'null' default
spoltier Mar 21, 2019
7481c41
WIP troubleshooting java xlcall method
spoltier May 27, 2019
9c8d767
poi 4.1.0 update dependency jars
spoltier Jun 7, 2019
a18e611
Updated XLConnect jar
spoltier Jun 27, 2019
32c28d3
POI 4.1.0 remove jar in wrong location
spoltier Jun 27, 2019
131f080
POI 4.1.0 - java changes recommended in review
spoltier Jul 11, 2019
6165a49
POI 4.1.0: released xlconnect java
spoltier Aug 22, 2019
1345a4c
#37: fix tests, use XLConnect java 1.0.0 + changes
spoltier Sep 5, 2019
6b91e0f
#37 updated xlconnect java
spoltier Sep 11, 2019
f306c37
#37: clean up code, add test case
spoltier Sep 11, 2019
03f8d92
#37 add negative test case
spoltier Sep 11, 2019
6b7cb22
#37 documentation
spoltier Sep 11, 2019
5fcf1c3
#37 fix doc of readNamedRegion
spoltier Sep 11, 2019
e357349
gh #37: write in specific sheet's named region
spoltier Sep 19, 2019
592b3fb
gh #37: create, check existence, and append to named region + tests
spoltier Sep 19, 2019
f713179
gh #37 clearNamedRegion of specified worksheet
spoltier Sep 26, 2019
d06f1f6
gh #37: add clear Named region test with worksheet name
spoltier Sep 26, 2019
c1bce16
#37 create name: set worksheet if name provided
spoltier Oct 2, 2019
c6c92e4
gh #37: sync jar, dev version
spoltier Aug 19, 2021
323eee5
#37 add and clean up doc
spoltier Aug 19, 2021
a5d6cf0
gh#37 test: formula sheet vs scope sheet
spoltier Sep 16, 2021
df60de7
gh#37 fix scope v formula - sheet property in java
spoltier Sep 16, 2021
e202356
#37 fix clearNamedRegion (java), cleanup, clearer doc
spoltier Sep 16, 2021
8538837
gh#37: remove jcenter, seems down
spoltier Sep 16, 2021
02f7a62
gh #37: test cloning names
spoltier Sep 16, 2021
46918e5
#37 fix cloning names (java)
spoltier Sep 16, 2021
a6973fa
#37 match worksheet name strictly (Java)
spoltier Sep 16, 2021
9215da0
gh#37 adapt doc to strict matching
spoltier Sep 16, 2021
a9fd7ed
#37 correct null check in readNamed...
spoltier Sep 16, 2021
e62d95f
Review: null handling / default value
spoltier Sep 23, 2021
310b45e
Review: parameter name change to '...scope'
spoltier Sep 23, 2021
c829e43
Review: write Named region - WIP?
spoltier Sep 23, 2021
41436ae
Review: write Named region - doc
spoltier Sep 23, 2021
c9f7b60
Review: use "" for explicit global scope
spoltier Sep 23, 2021
059ad99
Fix doc syntax
spoltier Sep 23, 2021
8dbdf9a
Review: worksheet scope for ref coordinates + doc fixes
spoltier Sep 23, 2021
57adf0e
Review: scoped removeName, doc fix
spoltier Sep 23, 2021
c02f065
Review: scoped addImage, missing default
spoltier Sep 23, 2021
16d52b6
Review - fix doc
spoltier Sep 23, 2021
301bd62
Review: addImage backwards compat
spoltier Sep 27, 2021
d09e70c
addImage fix doc
spoltier Sep 27, 2021
5bf2f4e
review: dimension-abiding readNamedRegion
spoltier Oct 7, 2021
4b23179
Restore full clear named region check
spoltier Oct 7, 2021
36679d6
Test write named to file with scope vector
spoltier Oct 7, 2021
1fd1301
Proposed fix, test change, fix read test
spoltier Oct 7, 2021
2630d8c
Fixed test
spoltier Oct 14, 2021
bc8bd0a
attributes (handling new java cls, setting attrs)
spoltier Oct 14, 2021
ac54ea3
processing attributes, working for n scopes
spoltier Oct 14, 2021
3fd2e4a
jar - handle null scope in create
spoltier Oct 21, 2021
ee748d6
Adapted attribute handling with suggested approach
spoltier Oct 21, 2021
90baa88
correctly set names
spoltier Oct 21, 2021
adf190a
clean up, ws scope attribute when null (jar)
spoltier Oct 28, 2021
856ef1f
WIP read named region attributes
spoltier Oct 28, 2021
f41be77
note after discussing with Riccardo
spoltier Oct 28, 2021
b327e96
attribute value is array of string
spoltier Oct 28, 2021
24c4a38
Attributes in dataframe from java
spoltier Oct 28, 2021
d3dcd2a
preserve attributes in extractRowNames
spoltier Nov 11, 2021
c17f149
use xlconnect-java rebased - with `overwriteFormulaCells`
spoltier Jan 10, 2024
33321bc
Jar from rebased XLConnect-java (refactoring)
spoltier Jan 17, 2024
4cc8aea
align xlcWithAttr... with changes to xlcCall
spoltier Jan 23, 2024
d8843d5
avoid overwriting names when setting attributes
spoltier Jan 23, 2024
8f40f53
checkTrue instead of checkExists for bool with attributes
spoltier Jan 23, 2024
64f6199
test write named region using (supported) scalar formula values only
spoltier Jan 23, 2024
f0f3b2c
Doc: fix argument order in writeNamedRegionToFile
spoltier Jan 23, 2024
be91641
combined version of xlcCall + Attributes
spoltier Jan 23, 2024
e5c3649
test that attributes are set on existsName
spoltier Jan 24, 2024
2d85051
test creating scoped names
spoltier Jan 24, 2024
3b40142
remove unused code, reorder lines for clarity
spoltier Jan 30, 2024
e2e9da4
define and test attributes toggle
spoltier Jan 30, 2024
b26fd61
implement attributes toggle
spoltier Jan 30, 2024
0287fc3
add scope param and clarify attribute handling in documentation
spoltier Jan 30, 2024
ac4c950
writeNamedRegionToFile: handle len(formula)>1
spoltier Jan 30, 2024
1cecbc9
refactoring: align function param order
spoltier Jan 30, 2024
97af014
missing in \usage of appendNamedRegion-methods
spoltier Feb 7, 2024
a7d460d
troubleshooting LaTeX output on newer R versions (?)
spoltier Feb 7, 2024
83649b7
fix itemize syntax
spoltier Feb 7, 2024
fdd6c18
line break not required
spoltier Feb 7, 2024
28c2cc9
test presence attributes on dataframes
spoltier Feb 14, 2024
82163cc
preserve java attributes on dataframes
spoltier Feb 14, 2024
6fc4f78
test: write then read two dataframes at once
spoltier Feb 14, 2024
c53e589
xlc-java candidate snapshot (refactored, no API changes)
spoltier Feb 14, 2024
7d1f06a
clean up debug statements
spoltier Feb 14, 2024
74be718
jar from CI build
spoltier Feb 14, 2024
32b4365
XLConnect jar with cleaned up code
spoltier Feb 21, 2024
4f5a35c
leave out scoped names when cloning
spoltier Mar 12, 2024
c1503b9
document effect of new option
spoltier Mar 12, 2024
b6e7578
draft NEWS
spoltier Mar 12, 2024
eda6ffc
readNamedRegion: worksheet scope negative case
spoltier Apr 3, 2024
c7dd13c
clean up: reword doc, code formatting, comments
spoltier Apr 9, 2024
a7b93e2
.recycle=FALSE as of previous impl. in getDefinedNames
spoltier Apr 9, 2024
7475c1b
simplified formula handling in writeNamedRegionToFile
spoltier Apr 9, 2024
b4b9003
add examples for existsName, read/ write named region
spoltier Apr 9, 2024
1dcafea
return attributes for getReferenceCoordinatesForName
spoltier Apr 9, 2024
7980902
worksheet scope attribute values for getDefinedNames
spoltier Apr 9, 2024
306d2c7
doc: reflect getDefinedNames in changes, more explicit attribute name
spoltier Apr 10, 2024
f58749d
attributes on getReferenceFormula
spoltier Apr 10, 2024
f437c8b
doc review named range / named region
spoltier Apr 10, 2024
c0dd345
more user-friendly name for attribute toggle
spoltier Apr 10, 2024
97dc2d8
jar from rebased xlconnect-java
spoltier May 7, 2024
ff09dad
remove old xlc jar (rebase leftover)
spoltier May 7, 2024
c3c7fdb
final JAR built on xlc-java master
spoltier May 15, 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
2 changes: 0 additions & 2 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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 @@ -45,7 +44,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
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.10
Version: 1.1.0.9999
Authors@R: c(person("Mirai Solutions GmbH", role = "aut",
email = "[email protected]"),
person("Martin", "Studer", role = "cre",
Expand Down
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
XLConnect News
--------------

1.1.0 tbd

* Support for worksheet scoped names including [#37](https://github.com/miraisolutions/xlconnect/issues/37)
* specify scope of names when writing and reading names, and more
* new option to receive information on the scope in which a name was found

1.0.9 2024-04-17
* Use com.zaxxer.sparsebits.SparseBitSet instead of java.util.BitSet
* (#212) fix for loading relative path workbooks under Java 8
Expand Down
2 changes: 2 additions & 0 deletions R/XLConnectSettings.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ XLConnectSettings <- function(pdesc) {
options(XLConnect.Sheet = "#xlc#")
# Rowname column (used by xlcDump, xlcRestore)
options(XLConnect.RownameCol = ".rownames")

options(XLConnect.setCustomAttributes = FALSE)

invisible()
}
11 changes: 7 additions & 4 deletions R/dataframeFromJava.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,12 @@ dataframeFromJava <- function(df, check.names) {
res[[i]] = v
}

# Apply names
names(res) = columnNames

data.frame(res, check.names = check.names, stringsAsFactors = FALSE)
# Preserve attributes
toSet = (attributes(df))[!names(attributes(df)) %in% c("jobj", "jclass", "class", "package")]
names(res) = columnNames
result = data.frame(res, check.names = check.names, stringsAsFactors = FALSE)
# combine attributes to avoid overwriting names, rownames, colnames
attributes(result) <- c(attributes(result), toSet)
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-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/>.
#
#############################################################################

#############################################################################
#
# Utility function for converting XLConnect java objects with added attributes
# to R variables with the corresponding attributes.
# Sets the attributes if option XLConnect.setCustomAttributes is TRUE.
# Otherwise only unwraps the java object.
#
# Author: Simon Poltier, Mirai Solutions GmbH
#
#############################################################################

withAttributesFromJava <- function(jobj) {

unwrapped <- jobj$getValue()
allANames = .jcall(jobj, "[S", "getAttributeNames")

if(getOption("XLConnect.setCustomAttributes")){
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, header, overwriteFormulaCells, worksheetScope %||% .jnull(), .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()
}
)
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, formula, overwrite, worksheetScope %||% .jnull())
invisible()
}
)
74 changes: 37 additions & 37 deletions R/workbook.existsName.R
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
#############################################################################
#
# 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/>.
#
#############################################################################
#############################################################################
#
# Checking existence of names in a workbook
#
# Author: Martin Studer, Mirai Solutions GmbH
#
#############################################################################
setGeneric("existsName",
function(object, name) standardGeneric("existsName"))
setMethod("existsName",
signature(object = "workbook"),
function(object, name) {
xlcCall(object, "existsName", name)
}
)
#############################################################################
#
# 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/>.
#
#############################################################################

#############################################################################
#
# Checking existence of names in a workbook
#
# Author: Martin Studer, Mirai Solutions GmbH
#
#############################################################################

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

setMethod("existsName",
signature(object = "workbook"),
function(object, name, worksheetScope = NULL) {
xlcCall(object, "existsName", name, worksheetScope %||% .jnull(), .withAttributes = TRUE)
}
)
Loading
Loading