将数据放入特定标头
headers = ["05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22"]
data = ["05:01", "05:23", "05:43", "06:03", "06:33", "06:53", "07:03", "07:23", "07:46", "08:04", "08:24", "08:44", "09:14", "09:24", "09:44", "10:19", "10:39", "11:02", "11:22", "11:42", "12:12", "12:32", "12:52", "13:12", "13:32", "13:52", "14:12", "14:32", "14:42", "15:02", "15:32", "15:52", "16:12", "16:32", "16:52", "17:12", "17:32", "17:52", "18:12", "18:47", "19:23", "19:48", "20:28", "21:03", "21:33", "22:08", "22:40"]
我必须将特定数据放入正确的标题中。例如
05 06
05:01 06:03
05:23 06:33
05:43 06:53
Rails 3.0.3
Ruby 1.9.2
Prawn 0.8.4
我怎样才能做到这一点?
基本上我想做这样的事情。
Prawn::Document.generate(path) do
table([['05','06']] + [['05:01','06:03'],['05:23','06:33'],['05:43','06:53']], :header => true) do
end
end
headers = ["05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22"]
data = ["05:01", "05:23", "05:43", "06:03", "06:33", "06:53", "07:03", "07:23", "07:46", "08:04", "08:24", "08:44", "09:14", "09:24", "09:44", "10:19", "10:39", "11:02", "11:22", "11:42", "12:12", "12:32", "12:52", "13:12", "13:32", "13:52", "14:12", "14:32", "14:42", "15:02", "15:32", "15:52", "16:12", "16:32", "16:52", "17:12", "17:32", "17:52", "18:12", "18:47", "19:23", "19:48", "20:28", "21:03", "21:33", "22:08", "22:40"]
I must put specific data to correct header. For example
05 06
05:01 06:03
05:23 06:33
05:43 06:53
Rails 3.0.3
Ruby 1.9.2
Prawn 0.8.4
How I can do that ?
Basically i want do something like this.
Prawn::Document.generate(path) do
table([['05','06']] + [['05:01','06:03'],['05:23','06:33'],['05:43','06:53']], :header => true) do
end
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此代码将给出如下输出:
You can also create a hash by edit last line
你可以通过这样做来达到 Prawn 的要求
This code will give output like this:
You can also create a hash by editing last line
You can acheive Prawn requirement by doing this
如果您询问如何向数组添加新元素,方法
push
将完成这项工作:If you are asking about how to add a new element to an array, method
push
will do the job: