Exporting dataframe from R to Excel with styles and formatting - r

I would like to export a large table (similar to that shown in the image below) to Excel with parts of the string highlighted in few of the columns.
At present I am displaying the table columns using datatable employing rowCallback function to highlight the sub string. Then to export the table to Excel, I am manually copying the rows from the displayed datatable to an Excel worksheet.
I could not accomplish this particular challenge using openxlsx or other libraries.
Please advice on how to overcome this challenge!

Related

How to add excel sheet cell comments in R

I am currently cleaning survey data in R. The output will be an excel sheet. I am currently using this comment code to have comments appear in the top row of the excel sheet to explain variable names. An example of this code is: comment(ExitClean$Q1a_1)<-c("name"). While the code runs, it does not consistently create comments in the final excel sheet output. Is there a more updated package or code to use to ensure that these comments appear in the output?

Is there a R function to add data from a df and append it to a sheet in excel

I have a R code that uses joins from various tables and finally have an output dataframe. I need this to be appended to a new worksheet in excel file that already has three sheets in it. I am on a mac and however I try the library(rjava) that is required for library(xlsx) wont load. Is there any other library (that doesnt need java) that I can use for this?
Edit to add: the existing excel sheet has graphs and charts in it

Can I filter out rows in a flextable after creating the flextable in rmarkdown?

I have a table output to a word doc in rmarkdown using FlexTable. I import the data for the table (which is a bunch of character strings) from a seperate excel file that I use for keeping a record. I need to be able to have parts of the table reprinted throughout different parts of the final report. Is there a way to filter out rows once the table is created so I can easily save all of the formatting? Or is that something I would have to do to the imported data and THEN create a flextable? Hope that all makes sense. Thank you!
Unfortunately, it seems that you cannot.
This has been stated by the developer of the package, as you can see in this issue on GitHub: https://github.com/davidgohel/flextable/issues/95.

ReporteRs: How to write formatted table to both pptx and xlsx?

I need a way to automatically create a powerpoint presentation with formatted tables of numbers, then also print these same tables to excel.
I currently have a formatted FlexTable object which I write to a powerpoint presentation with no issues using ReporteRs, but I am stuck on how to write the same table to Excel without having to go through all the formatting steps again.
Within R, Is there a way to either:
A) Write a flextable formatted object from R to excel?
or
B) Copy a formatted Excel table from xlsx file to powerpoint?
All thoughts appreciated!

Export gridview to csv

I am trying export gridview to csv.
I am adding actual record into cell of excel not trying html to excel.
I am executing sp, taking record into datatable.
Looping through datatable, writing into file using streamwriter.
But problem occur when my column has long number, csv shows 890+32 like this.
I don't want like this, want actual number like 89012345676898899998776766544333445556677.
How to do that? I am not using Gridview.RenderControl(htmltextwrtter).
Try to cast the number into a String and add a leading ' to force excel to see the entry as text, like this:
'89012345676898899998776766544333445556677
Otherwise excel will see them as numbers (which they are, of course) and auto-format them in the unwanted format.

Resources