forked from pteridin/flexlsx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
60 lines (42 loc) · 1.88 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# flexlsx <img src="man/figures/logo.png" align="right" height="126"/>
<!-- badges: start -->
[](https://lifecycle.r-lib.org/articles/stages.html#experimental) [](https://app.codecov.io/gh/pteridin/flexlsx?branch=main)
[](https://github.com/pteridin/flexlsx/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
The primary objective of `flexlsx` is to offer an effortless interface for exporting `flextable` objects directly to Microsoft Excel. Building upon the robust foundation provided by `openxlsx2` and `flextable`, `flexlsx` ensures compatibility, precision, and efficiency when working with both trivial and complex tables.
## Installation
You can install the development version of `flexlsx` like so:
``` r
# install.packages("remotes")
remotes::install_github("pteridin/flexlsx")
```
Or install the CRAN release like so:
``` r
install.packages("flexlsx")
```
## Example
This is a basic example which shows you how to solve a common problem:
``` r
library(flexlsx)
# Create a flextable and an openxlsx2 workbook
ft <- flextable::as_flextable(table(mtcars[,1:2]))
wb <- openxlsx2::wb_workbook()$add_worksheet("mtcars")
# add the flextable ft to the workbook, sheet "mtcars"
# offset the table to cell 'C2'
wb <- wb_add_flextable(wb, "mtcars", ft, dims = "C2")
# save the workbook to a temporary xlsx file
tmpfile <- tempfile(fileext = ".xlsx")
wb$save(tmpfile)
```