openxlsx

R - Autofit Excel column width

≯℡__Kan透↙ 提交于 2020-01-12 02:22:06
问题 How do I autofit the column width using openxlsx ? One of my columns has a date variable (eg. 21-08-2017 ) and if copied using ctrl+c from Excel, and pasted normally elsewhere, it shows like ####### (if column width is increased to show the content in Excel, it pastes normally). I want to integrate that repeatitive task into my code. Here is what I am using right now: WB <- loadWorkbook(File) addWorksheet(WB, Sheet) writeDataTable(WB, Sheet, DF, withFilter=F, bandedRows=F, firstColumn=T)

How to detect TIME when reading from an excel sheet using R

梦想的初衷 提交于 2019-12-25 00:23:34
问题 The issue is that when I read from an excel sheet into R using read.xlsx from openxlsx package, the TIME column is converted into a fraction. Here is an example, dfin <- DATE TIME 15/02/2015 8:00 AM 22/01/2014 10:00 PM library(openxlsx) test <- read.xlsx("dfin.xlsx", sheet = 1, detectDates=TRUE, skipEmptyRows = TRUE, skipEmptyCols = TRUE, rows = NULL, cols = NULL, check.names = FALSE, namedRegion = NULL, na.strings = "NA", fillMergedCells = FALSE) Output: DATE TIME 2015-02-15 0.3333333 2014

Read and write a xlsm file using exceljs package npm

家住魔仙堡 提交于 2019-12-24 02:31:25
问题 I have a xlsm file with few data already in it and need to write some data and create a new xlsm file during automation. With below code the file gets created , but it becomes corrupt and unable to open. File size reduces, for ex from 8kb to 7kb. Not sure what is getting missed while writing the file. var Excel = require('exceljs'); var workbook = new Excel.Workbook(); workbook.xlsx.readFile('Book.xlsm') .then(function () { var worksheet = workbook.getWorksheet(1); var row = worksheet.getRow

Excel import to data frame in R with formulas

橙三吉。 提交于 2019-12-13 18:24:20
问题 I coded the answer to my issue and it is follow up from Data import and text to column (when in excel A1 = 1+1+1 and 3 is visible) The code below works but I wonder if there is any way to improve it. I mean I import the same sheet twice as I could not find a way to maintain other columns after I extract formulas from Col_2. So, I have got excel file with 3 columns. Col_1 is text, Col_2 has got simple formula, for example B2 = 2+2; B3 = 3+3 etc...Col_3 is just to highlight my problem. I import

Use R and Openxlsx to output a list of dataframes as worksheets in a single Excel file

不想你离开。 提交于 2019-12-12 08:42:41
问题 I have a set of CSV files. I want to package them up and export the data to a single Excel file that contains multiple worksheets. I read in the CSV files as a set of data frames. My problem is how to construct the command in openxlsx , I can do it manually, but I am having a list construction issue. Specifically how to add a data frame as a subcomponent of a named list and then pass as a parameter to write.xlsx() Example Ok, so I first list the CSV files on disk and generate a set of data

Use R and Openxlsx to output a list of dataframes as worksheets in a single Excel file

馋奶兔 提交于 2019-12-04 03:24:25
I have a set of CSV files. I want to package them up and export the data to a single Excel file that contains multiple worksheets. I read in the CSV files as a set of data frames. My problem is how to construct the command in openxlsx , I can do it manually, but I am having a list construction issue. Specifically how to add a data frame as a subcomponent of a named list and then pass as a parameter to write.xlsx() Example Ok, so I first list the CSV files on disk and generate a set of data frames in memory... # Generate a list of csv files on disk and shorten names... filePath <- "..

How do I modify an existing a sheet in an Excel Workbook using Openxlsx package in R?

久未见 提交于 2019-12-02 23:17:10
I am using "openxlsx" package to read and write excel files. I have a fixed file with a sheet called "Data" which is used by formulas in other sheets. I want to update this Data sheet without touching the other. I am trying the following code: write.xlsx(x = Rev_4, file = "Revenue.xlsx", sheetName="Data") But this erases the excel file and creates a new one with just the new data in the "Data" sheet while all else gets deleted. Any Advice? Try this: wb <- loadWorkbook("Revenue.xlsx") writeData(wb, sheet = "Data", Rev_4, colNames = F) saveWorkbook(wb,"Revenue.xlsx",overwrite = T) You need to

How do I modify an existing a sheet in an Excel Workbook using Openxlsx package in R?

折月煮酒 提交于 2019-11-29 03:07:50
问题 I am using "openxlsx" package to read and write excel files. I have a fixed file with a sheet called "Data" which is used by formulas in other sheets. I want to update this Data sheet without touching the other. I am trying the following code: write.xlsx(x = Rev_4, file = "Revenue.xlsx", sheetName="Data") But this erases the excel file and creates a new one with just the new data in the "Data" sheet while all else gets deleted. Any Advice? 回答1: Try this: wb <- loadWorkbook("Revenue.xlsx")