Hiding Columns in Excel Workbooks using openxlsx

我的梦境 提交于 2020-04-07 03:34:53

问题


I'm trying to hide columns in an Excel workbook I'm creating using the openxlsx package in R, but I'm not having any luck. I could make a pre-formatted Excel workbook and write data to it, but the number of columns that need to be hidden is variable. I've tried using:

 setColWidths(wb, sheet = "Sheet 1", cols = col_list, widths = 0)

where "col_list" is the list of columns that need to be hidden. When I open the saved workbook, the column widths are actually 0.38. If anybody has any ideas on how I might go about this, it would be much appreciated.


回答1:


The documentation shows the fields for the formula as below:

setColWidths(wb, sheet, cols, widths = 8.43, hidden = rep(FALSE, length(cols)), ignoreMergedCells = FALSE)

So setting hidden = rep(TRUE, length(cols)) should hide your columns



来源:https://stackoverflow.com/questions/41961187/hiding-columns-in-excel-workbooks-using-openxlsx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!