forked from ropensci/writexl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0ca88e4
Showing
68 changed files
with
39,995 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^src/.*\.a$ | ||
^src/.*\.o$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
*.so | ||
*.o | ||
*.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Package: writexl | ||
Type: Package | ||
Title: Export R Data Frames to xlsx Format | ||
Version: 0.1 | ||
Authors@R: c( | ||
person("Jeroen", "Ooms", ,"[email protected]", role = c("aut", "cre")), | ||
person("John McNamara", role = "cph", comment = "Author of libxlsxwriter")) | ||
Description: Light weight data frame to xlsx exporter based on libxlsxwriter. | ||
No Java or Excel required. | ||
License: MIT + file LICENSE | ||
Encoding: UTF-8 | ||
LazyData: true | ||
URL: https://libxlsxwriter.github.io (upstream) | ||
RoxygenNote: 6.0.1 | ||
Suggests: readxl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
YEAR: 2017 | ||
COPYRIGHT HOLDER: Jeroen Ooms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(lxw_version) | ||
export(write_xlsx) | ||
useDynLib(writexl,C_lxw_version) | ||
useDynLib(writexl,C_write_data_frame) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#' Version | ||
#' | ||
#' Shows version of bundled libxlsxwriter. | ||
#' | ||
#' @export | ||
#' @rdname writexl | ||
#' @useDynLib writexl C_lxw_version | ||
lxw_version <- function(){ | ||
version <- .Call(C_lxw_version) | ||
as.numeric_version(version) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#' Export to xlsx | ||
#' | ||
#' Writes a data frame to an xlsx file. | ||
#' | ||
#' @export | ||
#' @aliases writexl | ||
#' @useDynLib writexl C_write_data_frame | ||
#' @param x data frame to write to disk | ||
#' @param path a file name to write to | ||
#' @param col_names write column names at the top of the file? | ||
#' @examples tmp <- write_xlsx(iris) | ||
#' readxl::read_xlsx(tmp) | ||
write_xlsx <- function(x, path = tempfile(fileext = ".xlsx"), col_names = TRUE){ | ||
stopifnot(is.data.frame(x)) | ||
stopifnot(is.character(path)) | ||
df <- normalize_df(x) | ||
headers <- if(isTRUE(col_names)) | ||
colnames(x) | ||
.Call(C_write_data_frame, df, path, headers) | ||
} | ||
|
||
normalize_df <- function(df){ | ||
for(i in which(vapply(df, is.factor, logical(1)))){ | ||
df[[i]] <- as.character(df[[i]]) | ||
} | ||
for(i in which(vapply(df, inherits, logical(1), "POSIXlt"))){ | ||
df[[i]] <- as.POSIXct(df[[i]]) | ||
} | ||
df | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
LIBXLSXWRITER = \ | ||
libxlsxwriter/app.o libxlsxwriter/format.o libxlsxwriter/theme.o \ | ||
libxlsxwriter/chart.o libxlsxwriter/hash_table.o libxlsxwriter/utility.o \ | ||
libxlsxwriter/content_types.o libxlsxwriter/packager.o libxlsxwriter/workbook.o \ | ||
libxlsxwriter/core.o libxlsxwriter/relationships.o libxlsxwriter/worksheet.o \ | ||
libxlsxwriter/custom.o libxlsxwriter/shared_strings.o libxlsxwriter/xmlwriter.o \ | ||
libxlsxwriter/drawing.o libxlsxwriter/styles.o tmpfileplus/tmpfileplus.o \ | ||
minizip/ioapi.o minizip/mztools.o minizip/zip.o minizip/unzip.o | ||
|
||
STATICLIB=libxlsxwriter/libstatxlsxwriter.a | ||
|
||
PKG_CFLAGS=$(C_VISIBILITY) | ||
PKG_CPPFLAGS=-Iinclude | ||
PKG_LIBS=-Llibxlsxwriter -lstatxlsxwriter -lz | ||
|
||
all: clean | ||
|
||
$(SHLIB): $(STATICLIB) | ||
|
||
$(STATICLIB): $(LIBXLSXWRITER) | ||
$(AR) rcs $(STATICLIB) $(LIBXLSXWRITER) | ||
|
||
clean: | ||
rm -f $(SHLIB) $(STATICLIB) $(OBJECTS) $(LIBXLSXWRITER) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* libxlsxwriter | ||
* | ||
* Copyright 2014-2017, John McNamara, [email protected]. See LICENSE.txt. | ||
*/ | ||
|
||
/** | ||
* @file xlsxwriter.h | ||
* | ||
* xlsxwriter - A library for creating Excel XLSX files. | ||
* | ||
*/ | ||
#ifndef __LXW_XLSXWRITER_H__ | ||
#define __LXW_XLSXWRITER_H__ | ||
|
||
#include "xlsxwriter/workbook.h" | ||
#include "xlsxwriter/worksheet.h" | ||
#include "xlsxwriter/format.h" | ||
#include "xlsxwriter/utility.h" | ||
|
||
#define LXW_VERSION "0.7.4" | ||
|
||
#endif /* __LXW_XLSXWRITER_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* libxlsxwriter | ||
* | ||
* Copyright 2014-2017, John McNamara, [email protected]. See LICENSE.txt. | ||
* | ||
* app - A libxlsxwriter library for creating Excel XLSX app files. | ||
* | ||
*/ | ||
#ifndef __LXW_APP_H__ | ||
#define __LXW_APP_H__ | ||
|
||
#include <stdint.h> | ||
#include <string.h> | ||
#include "workbook.h" | ||
#include "common.h" | ||
|
||
/* Define the queue.h TAILQ structs for the App structs. */ | ||
STAILQ_HEAD(lxw_heading_pairs, lxw_heading_pair); | ||
STAILQ_HEAD(lxw_part_names, lxw_part_name); | ||
|
||
typedef struct lxw_heading_pair { | ||
|
||
char *key; | ||
char *value; | ||
|
||
STAILQ_ENTRY (lxw_heading_pair) list_pointers; | ||
|
||
} lxw_heading_pair; | ||
|
||
typedef struct lxw_part_name { | ||
|
||
char *name; | ||
|
||
STAILQ_ENTRY (lxw_part_name) list_pointers; | ||
|
||
} lxw_part_name; | ||
|
||
/* Struct to represent an App object. */ | ||
typedef struct lxw_app { | ||
|
||
FILE *file; | ||
|
||
struct lxw_heading_pairs *heading_pairs; | ||
struct lxw_part_names *part_names; | ||
lxw_doc_properties *properties; | ||
|
||
uint32_t num_heading_pairs; | ||
uint32_t num_part_names; | ||
|
||
} lxw_app; | ||
|
||
|
||
/* *INDENT-OFF* */ | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
/* *INDENT-ON* */ | ||
|
||
lxw_app *lxw_app_new(); | ||
void lxw_app_free(lxw_app *app); | ||
void lxw_app_assemble_xml_file(lxw_app *self); | ||
void lxw_app_add_part_name(lxw_app *self, const char *name); | ||
void lxw_app_add_heading_pair(lxw_app *self, const char *key, | ||
const char *value); | ||
|
||
/* Declarations required for unit testing. */ | ||
#ifdef TESTING | ||
|
||
STATIC void _app_xml_declaration(lxw_app *self); | ||
|
||
#endif /* TESTING */ | ||
|
||
/* *INDENT-OFF* */ | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
/* *INDENT-ON* */ | ||
|
||
#endif /* __LXW_APP_H__ */ |
Oops, something went wrong.