简体   繁体   English

使用axlsx gem隐藏工作表

[英]Hide Work sheet with axlsx gem

I am using axlsx 2.0.1 gem to generate spreadsheets. 我正在使用axlsx 2.0.1 gem生成电子表格。 I came to situation in which I have to hide some worksheets. 我遇到不得不隐藏一些工作表的情况。 In examples it is given that you can hide the sheet with: 在示例中,可以使用以下方法隐藏工作表:

 wb.add_worksheet name: 'hidden', state: :hidden do |sheet|
    sheet.add_row ['you cant see me!']
  end

But this is not working with it. 但这不起作用。 Then after, I'd included gem with 然后,我将宝石与

gem 'axlsx', git: "git@github.com:randym/axlsx.git"

And then it worked. 然后它起作用了。 So what should I do then? 那我该怎么办呢? Should I continue with the git url or something else? 我应该继续使用git url还是其他?

The problem is that the author of this gem has not released an updated version in RubyGems since last September. 问题在于,自去年9月以来,该宝石的作者尚未在RubyGems中发布更新版本。 You can see that by visiting the gem's entry in RubyGems . 您可以通过访问RubyGems中gem的条目来看到。 As you can see, the latest release (2.0.1) happened 13/9/2013. 如您所见,最新版本(2.0.1)发生在13/9/2013。

As the feature you are interested in was added after that on the gem's master branch, having a git URL in your Gemfile works fine for you. 由于您感兴趣的功能是在gem的master分支之后添加的,因此在Gemfile中具有git URL对您来说很好。 However this is far from ideal for production systems! 但是,这对于生产系统而言远非理想! Any changes in the gem's master branch (which is not always stable or well-tested) could end up in your project if you were to (inadvertently) update this gem. 如果您要(无意间)更新此gem,则gem的master分支中的任何更改(并不总是稳定或经过良好测试)都可能会落入您的项目中。

You could fork the project on github and use the forked URL in your Gemfile to ensure that no changes happen overnight. 您可以将该项目存储在github上,并在Gemfile中使用分叉的URL,以确保不会在一夜之间发生任何更改。 Or you could search for a git tag that represents the project in the state you desire it (ie after the hidden-sheets feature was implemented). 或者,您可以搜索一个git标签,该标签以您期望的状态(即在实现隐藏工作表功能之后)代表该项目。 You could even set a specific commit hash in your Gemfile if you want! 如果需要,您甚至可以在Gemfile中设置特定的提交哈希!

Once the author releases a new stable version of his gem and after you ensure that it works fine for you (eg there are no regressions), you can change back your Gemfile to the simpler gem 'axlsl' . 一旦作者发布了自己的gem的新稳定版本,并确保您可以正常使用(例如,没有回归),您就可以将Gemfile改回更简单gem 'axlsl'

If you want to see how you can specify a certain branch, commit, or tag in your Gemfile have a look here: How to get a specific "commit" of a gem from github? 如果要查看如何在Gemfile中指定某个分支,提交或标记,请看这里: 如何从github获取gem的特定“提交”?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM