使用R包openxlsx将样式应用于整个Excel工作表

时间:2019-02-25 00:11:04

标签: r excel openxlsx

我正在使用一个名为 openxlsx 的R包。我创建了如下所示的int write_file( char *argv[]) { int fd, fd_in; off_t size; off_t file_index; char* fname = 0; char* addr = argv[3]; fname = argv[2]; fd_in = open(fname, O_RDONLY); if (fd_in < 1) { printf("Unable to open input file %s\n",fname ); } void* load_address = (void*)strtoul(addr, NULL, 16); printf("Loading at address %p\n ",load_address); fd = open("/dev/mem", O_RDWR | O_SYNC); if (fd < 1) { printf("Unable to open mem device file\n"); close(fd_in); return -1; } // determine size size = lseek(fd_in, 0L, SEEK_END); lseek(fd_in, 0L, SEEK_SET); printf("Copying %ld bytes\n", size); base_address = mmap(load_address, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_UNINITIALIZED | MAP_FIXED, fd, 0); if (base_address == MAP_FAILED) { printf("mmap failed! %s\n", strerror(errno)); close(fd); close(fd_in); return -1; } for (file_index = 0; file_index < size; file_index++) { uint8_t file_byte; ssize_t result = read(fd_in, &file_byte,1); if (result<0) { printf("Error during fileread: %s", strerror(errno)); break; } base_address[file_index] = file_byte; if (base_address[file_index] != file_byte) { printf("Write failed, offset %lx failed\n", file_index); break; } if ((file_index % 100) == 0) { printf("."); } } printf("\n"); munmap(base_address, size); close(fd_in); close(fd); return 0; } 。我想将此样式应用于标题为“ test-sheet”的整个工作表。当我尝试将此样式应用于Excel工作表的所有行和所有列时,我得到一个AlignStyle

Error in 1:Inf : result would be too long a vector

我知道我可以做类似# Define a style AlignStyle <- createStyle(halign = "CENTER", valign = "TOP") # Apply the style addStyle(wb, "test-sheet", style = AlignStyle, rows = 1:Inf, cols = 1:Inf, gridExpand = TRUE) 的事情,但是我的数据框的名称并不总是rows = 1:nrows(df)

您是否知道我可以使用 openxlsx R包将样式应用于整个工作表或整个工作簿的另一种方式?

0 个答案:

没有答案