<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/the-writexl-package-zero-dependency-xlsx-writer-for-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://ropensci.org/blog/technotes/2017/09/08/writexl-release"> rOpenSci Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>We have started working on a new rOpenSci package called <a rel="nofollow" href="https://github.com/ropensci/writexl#readme" target="_blank">writexl</a>. This package wraps the very powerful <a rel="nofollow" href="https://libxlsxwriter.github.io/" target="_blank">libxlsxwriter</a> library which allows for exporting data to Microsoft Excel format.</p>
<p>The major benefit of writexl over other packages is that it is completely written in C and has absolutely zero dependencies. No Java, Perl or Rtools are required.</p>
<h2>Getting Started</h2>
<p>The <code>write_xlsx</code> function writes a data frame to an xlsx file. You can test that data roundtrips properly by reading it back using the readxl package. Columns containing dates and factors get automatically coerced to character strings.</p>
<div>
<pre><code data-lang="r"><span></span><span>library</span><span>(</span>writexl<span>)</span>
<span>library</span><span>(</span>readxl<span>)</span>
write_xlsx<span>(</span>iris<span>,</span> <span>&quot;iris.xlsx&quot;</span><span>)</span>

<span># read it back</span>
out <span>&lt;-</span> read_xlsx<span>(</span><span>&quot;iris.xlsx&quot;</span><span>)</span>
</code></pre>
</div>
<p>You can also give it a named list of data frames, in which case each data frame becomes a sheet in the xlsx file:</p>
<div>
<pre><code data-lang="r"><span></span>write_xlsx<span>(</span><span>list</span><span>(</span>iris <span>=</span> iris<span>,</span> cars <span>=</span> cars<span>,</span> mtcars <span>=</span> mtcars<span>),</span> <span>&quot;mydata.xlsx&quot;</span><span>)</span>
</code></pre>
</div>
<p>Performance is good too; in our benchmarks writexl is about twice as fast as openxlsx:</p>
<div>
<pre><code data-lang="r"><span></span><span>library</span><span>(</span>microbenchmark<span>)</span>
<span>library</span><span>(</span>nycflights13<span>)</span>
microbenchmark<span>(</span>
  writexl <span>=</span> writexl<span>::</span>write_xlsx<span>(</span>flights<span>,</span> <span>tempfile</span><span>()),</span>
  openxlsx <span>=</span> openxlsx<span>::</span>write.xlsx<span>(</span>flights<span>,</span> <span>tempfile</span><span>()),</span>
  times <span>=</span> <span>5</span>
<span>)</span>
<span>## Unit: seconds</span>
<span>## expr min lq mean median uq max neval</span>
<span>## writexl 8.884712 8.904431 9.103419 8.965643 9.041565 9.720743 5</span>
<span>## openxlsx 17.166818 18.072527 19.171003 18.669805 18.756661 23.189206 5</span>
</code></pre>
</div>
<h2>Roadmap</h2>
<p>The initial version of writexl implements the most important functionality for R users: exporting data frames. However the underlying <a rel="nofollow" href="https://libxlsxwriter.github.io/" target="_blank">libxlsxwriter</a> library actually provides far more sophisticated functionality such as custom formatting, writing complex objects, formulas, etc.</p>
<p>Most of this probably won't be useful to R users. But if you have a well defined use case for exposing some specific features from the library in writexl, <a rel="nofollow" href="https://github.com/ropensci/writexl/issues" target="_blank">open an issue</a> on Github and we'll look into it!</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://ropensci.org/blog/technotes/2017/09/08/writexl-release"> rOpenSci Blog</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/Gyp3M2HZzII" height="1"></a></div>