[英]R: Hide worksheet with package xlsx
I've had great success with the R package xlsx for many things. R 包 xlsx 在很多方面都取得了巨大的成功。 However, in the documentation, it says "the user has control to set colors, fonts, data formats, add borders, hide/unhide sheets , add/remove rows, add/remove sheets, etc."
然而,在文档中,它说“用户可以控制设置颜色、字体、数据格式、添加边框、隐藏/取消隐藏工作表、添加/删除行、添加/删除工作表等。” (Emphasis mine.)
(强调我的。)
However, I've scoured the documentation and can't find the function to hide sheets.但是,我浏览了文档,找不到隐藏工作表的功能。 Can someone point me to it?
有人可以指出我吗? Thanks!
谢谢!
Documentation at http://cran.r-project.org/web/packages/xlsx/xlsx.pdf if this helps.如果有帮助,请参阅 http://cran.r-project.org/web/packages/xlsx/xlsx.pdf 上的文档。
So that others having the same problem can find the answer, here is how developer Adrian Dragulescu replied to my email: 因此,其他有相同问题的人可以找到答案,以下是开发人员Adrian Dragulescu如何回复我的电子邮件:
Once you have a workbook 一旦你有了工作簿
wb <- createWorkbook()
you can do 你可以做
wb$setSheetHidden(0L, 1L)
if you want to hide the first sheet (0-based indexing in Java). 如果要隐藏第一个工作表(Java中基于0的索引)。 See the documentation here: http://poi.apache.org/apidocs/org/apache/poi/xssf/usermodel/XSSFWorkbook.html#setSheetHidden(int , int)
请参阅此处的文档: http : //poi.apache.org/apidocs/org/apache/poi/xssf/usermodel/XSSFWorkbook.html#setSheetHidden (int,int)
I can confirm this works, and many thanks to Mr. Dragulescu. 我可以确认这是有效的,非常感谢Dragulescu先生。
A solution using openxlsx
package:使用
openxlsx
包的解决方案:
openxlsx::addWorksheet(worksheetName, sheetName, visible = F) #hides
openxlsx::addWorksheet(worksheetName, sheetName, visible = F) #shows (default)
More info here: https://rdrr.io/cran/openxlsx/man/addWorksheet.html更多信息在这里: https : //rdrr.io/cran/openxlsx/man/addWorksheet.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.