使用openxlsx在Excel工作簿中隐藏列 [英] Hiding Columns in Excel Workbooks using openxlsx

查看:160
本文介绍了使用openxlsx在Excel工作簿中隐藏列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用R中的openxlsx包隐藏我正在创建的Excel工作簿中的列,但是我没有任何运气.我可以制作一个预先格式化的Excel工作簿并向其中写入数据,但是需要隐藏的列数是可变的.我尝试使用:

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)

其中"col_list"是需要隐藏的列的列表.当我打开保存的工作簿时,列的宽度实际上是0.38.如果有人对我将如何处理有任何想法,将不胜感激.

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.

推荐答案

文档显示了公式的字段,如下所示:

The documentation shows the fields for the formula as below:

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

因此设置hidden = rep(TRUE, length(cols))应该会隐藏您的列

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

这篇关于使用openxlsx在Excel工作簿中隐藏列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆