Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/janmarvin/openxlsx2
openxlsx2 - read, write and modify xlsx files
https://github.com/janmarvin/openxlsx2
r r-package xlsx
Last synced: about 19 hours ago
JSON representation
openxlsx2 - read, write and modify xlsx files
- Host: GitHub
- URL: https://github.com/janmarvin/openxlsx2
- Owner: JanMarvin
- License: other
- Created: 2021-07-10T10:05:32.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-23T18:00:05.000Z (5 days ago)
- Last Synced: 2024-12-24T08:44:56.089Z (4 days ago)
- Topics: r, r-package, xlsx
- Language: R
- Homepage: https://janmarvin.github.io/openxlsx2/
- Size: 33.4 MB
- Stars: 125
- Watchers: 6
- Forks: 13
- Open Issues: 31
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# openxlsx2
[![R-CMD-check](https://github.com/JanMarvin/openxlsx2/workflows/R-CMD-check/badge.svg)](https://github.com/JanMarvin/openxlsx2/actions)
[![codecov](https://codecov.io/gh/JanMarvin/openxlsx2/branch/main/graph/badge.svg?token=HEZ7rXcZNq)](https://app.codecov.io/gh/JanMarvin/openxlsx2)
[![r-universe](https://janmarvin.r-universe.dev/badges/openxlsx2)](https://janmarvin.r-universe.dev/openxlsx2)
[![CRAN status](https://www.r-pkg.org/badges/version/openxlsx2)](https://cran.r-project.org/package=openxlsx2)This R package is a modern reinterpretation of the widely used popular `openxlsx` package.
Similar to its predecessor, it simplifies the creation of xlsx files by providing a clean interface for writing, designing and editing worksheets.
Based on a powerful XML library and focusing on modern programming flows in pipes or chains, `openxlsx2` allows to break many new ground.## Installation
You can install the stable version of `openxlsx2` with:
``` r
install.packages('openxlsx2')
```You can install the development version of `openxlsx2` from [GitHub](https://github.com/) with:
``` r
# install.packages("remotes")
remotes::install_github("JanMarvin/openxlsx2")
```Or from [r-universe](https://janmarvin.r-universe.dev/openxlsx2) with:
```R
# Enable repository from janmarvin
options(repos = c(
janmarvin = 'https://janmarvin.r-universe.dev',
CRAN = 'https://cloud.r-project.org'))
# Download and install openxlsx2 in R
install.packages('openxlsx2')
```## Introduction
`openxlsx2` aims to be the swiss knife for working with the openxml spreadsheet formats xlsx, xlsm and (limited) xlsb (other formats of other spreadsheet software are not supported). We offer two different variants how to work with `openxlsx2`.
* The first one is to simply work with R objects. It is possible to read ([`read_xlsx()`](https://janmarvin.github.io/openxlsx2/reference/wb_to_df.html)) and write ([`write_xlsx()`](https://janmarvin.github.io/openxlsx2/reference/write_xlsx.html)) data from and to files. We offer a number of options in the commands to support various features of the openxml format, including reading and writing named ranges and tables. Furthermore, there are several ways to read certain information of an openxml spreadsheet without having opened it in a spreadsheet software before, e.g. to get the contained sheet names or tables.
* As a second variant `openxlsx2` offers the work with so called [`wbWorkbook`](https://janmarvin.github.io/openxlsx2/reference/wbWorkbook.html) objects. Here an openxml file is read into a corresponding `wbWorkbook` object ([`wb_load()`](https://janmarvin.github.io/openxlsx2/reference/wb_load.html)) or a new one is created ([`wb_workbook()`](https://janmarvin.github.io/openxlsx2/reference/wb_workbook.html)). Afterwards the object can be further modified using various functions. For example, worksheets can be added or removed, the layout of cells or entire worksheets can be changed, and cells can be modified (overwritten or rewritten). Afterwards the `wbWorkbook` objects can be written as openxml files and processed by suitable spreadsheet software.Many examples how to work with `openxlsx2` are in our [manual pages](https://janmarvin.github.io/openxlsx2/reference/index.html) and in our [vignettes](https://janmarvin.github.io/openxlsx2/articles/). You can find them under:
```r
vignette(package = "openxlsx2")
```## Example
This is a basic example which shows you how to solve a common problem:
```{r example}
library(openxlsx2)
# read xlsx or xlsm files
path <- system.file("extdata/openxlsx2_example.xlsx", package = "openxlsx2")
read_xlsx(path)# or import workbooks
wb <- wb_load(path)
wb# read a data frame
wb_to_df(wb)# and save
temp <- temp_xlsx()
if (interactive()) wb_save(wb, temp)## or create one yourself
wb <- wb_workbook()
# add a worksheet
wb$add_worksheet("sheet")
# add some data
wb$add_data("sheet", cars)
# open it in your default spreadsheet software
if (interactive()) wb$open()
```## Authors and contributions
For a full list of all authors that have made this package possible and for whom we are greatful, please see:
```r
system.file("AUTHORS", package = "openxlsx2")
```If you feel like you should be included on this list, please let us know.
If you have something to contribute, you are welcome.
If something is not working as expected, open issues or if you have solved an issue, open a pull request.
Please be respectful and be aware that we are volunteers doing this for fun in our unpaid free time.
We will work on problems when we have time or need.## License
This package is licensed under the MIT license and is based on [`openxlsx`](https://github.com/ycphs/openxlsx) (by Alexander Walker and Philipp Schauberger; COPYRIGHT 2014-2022) and [`pugixml`](https://github.com/zeux/pugixml) (by Arseny Kapoulkine; COPYRIGHT 2006-2023). Both released under the MIT license.