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

发布于 2024-12-15 22:09:23 字数 406 浏览 4 评论 0原文

我正在尝试更改 xlsx 文件的页面设置,以便将其打印为横向而不是纵向,我尝试了以下操作:

library(xlsx)

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

如果我创建一个新的 Excel 工作簿,这是可以的,但当我创建一个新的 Excel 工作簿时,我无法使用它我正在使用 loadWorkbook 函数加载 xls 文件。我想知道为什么。

更新:我正在处理 xls 文件,但不是 xlsx 文件,发现下面的答案无法解决我的问题,还有其他建议吗?谢谢。

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:

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. 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? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦冥 2024-12-22 22:09:23

我可以通过使用 getSheets 选择要设置打印区域的工作表来使其工作:

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

I can get it to work by using getSheets to select the sheet to set the print area for:

wb <- loadWorkbook("test.xlsx")
printSetup(getSheets(wb)[[1]], landscape=TRUE, copies=3)
saveWorkbook(wb,"test.xlsx")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文