我想知道我正在使用Axlsx gem 从我们系统中的数据生成 excel 文档。我有几个使用数据验证的工作表,所有公式都在一个名为列表的工作表上。是否可以隐藏该工作表,以免人们搞砸数据验证?
我查看了库,发现您可以隐藏行或列,但工作表却无处可去?
可以隐藏工作表。您只需定义其:state属性:
p = Axlsx::Package.new
wb = p.workbook
# Worksheets in the :hidden state can be shown using the sheet formatting
# properties in excel.
wb.add_worksheet name: 'hidden', state: :hidden do |sheet|
sheet.add_row ['you cant see me!']
end
# :very_hidden sheets should be inaccessible to end users.
wb.add_worksheet name: 'very hidden', state: :very_hidden do |sheet|
sheet.add_row ['you really cant see me!']
end
资料来源:
https://github.com/randym/axlsx/blob/master/examples/example.rb
https://github.com/randym/axlsx/blob/master/lib/axlsx/workbook/worksheet/worksheet.rb