简体   繁体   English

在R中使用xlsx包调整xlsx文件中的页面设置

[英]using xlsx package in R to adjust page setting in xlsx file

I am trying to change the page setting of a xlsx file so that it will be printed as landscape, but not portrait, I tried the following: 我试图更改xlsx文件的页面设置,以便将其打印为横向,而不是纵向,我尝试了以下操作:

library(xlsx)

wb <- createWorkbook()
sheet <- createSheet(wb, "Sheet1")
ps <- printSetup(sheet, landscape=TRUE, copies=3)

This is OK if I create a new Excel workbook, but I can't use it when I am using the loadWorkbook function to load an xls file. 如果创建一个新的Excel工作簿,则可以,但是使用loadWorkbook函数加载xls文件时,不能使用它。 I wonder why. 我想知道为什么。

Update : I am working on a xls file but not xlsx file and found the answer below cannot solve my problem, any further suggestions? 更新 :我正在处理xls文件,而不是xlsx文件,发现以下答案不能解决我的问题,还有其他建议吗? Thanks. 谢谢。

I can get it to work by using getSheets to select the sheet to set the print area for: 我可以通过使用getSheets选择工作表来设置打印区域来使其工作:

wb <- loadWorkbook("test.xlsx")
printSetup(getSheets(wb)[[1]], landscape=TRUE, copies=3)
saveWorkbook(wb,"test.xlsx")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM