We are trying to automate the creation of some picture files within an R
Script.
We have the Excel files looking the way that we want them to, but now need to make a JPG or PNG picture-copy of those excel tables for easier web posting.
We've been using the library(xlsx)
package for most of our interactions between R
and Excel, and it looks like we should be able to send specific java commands through something like ?.jmethods
but it's unclear how we would pass as many lines as we need to.
In an R
session, here's a minimal reproducible example...
Here's an example Excel file with a range to print
library(xlsx)
file <- system.file("tests", "test_import.xlsx", package = "xlsx")
file
And here's the Excel macro that exports the Excel range to a picture file
Sub Tester()
Worksheets("deletedFields").Range("A8:J36").CopyPicture xlScreen, xlBitmap
Application.DisplayAlerts = False
Set oCht = Charts.Add
With oCht
.Paste
.Export Filename:="C:empSavedRange.jpg", Filtername:="JPG"
.Delete
End With
End Sub
Any help automating this would be much appreciated!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…