我试图找出如何加载一个特定的创业板只有在需要时。在这里,情况如下:
我正在使用伟大的axlsx gem来创建Excel。我的应用程序中允许这样做的功能只在用户请求Excel文件时调用:
# model
require 'axlsx'
class AssessmentRaw < ActiveRecord::Base
# fun stuff here
def create_excel_file_io
xls = Axlsx::Package.new
# fun stuff here too
end
end
# a ca
尝试使用Ruby Sinatra和AXLSX gem提示下载窗口并流式传输XLSX文件时,我的excel文件成功地序列化为本地文件,因此我知道它是一个有效的excel文档,但我需要它来将内容传输给最终用户。目前还没有任何在线文档包含AXLS和Sinatra一起使用的示例,只有rails。感谢您的帮助!
class Downloads < Sinatra::Base
get '/downloads/report' do
## ...
Axlsx::Package.new do |p|
p.workbook.add_worksheet(name
我需要在SQL查询完成后呈现一个Excel模板。SQL需要3-4分钟才能完成。因此,我在ActiveJob中实现了SQL执行和excel模板渲染。 我将模板命名为my_template,如下所示: class RefreshReportDataJob < ApplicationJob
include SuckerPunch::Job
queue_as :default
def perform
# <- Run a SQL first here ->
# After SQL above is complete, render an Excel
我正在尝试用axlsx在后台生成excel文件并保存(Rails4.2)。在的GitHub页面上,写着As of Rails 4.1 you must use render_to_string to render a mail attachment。但是,它抛出了一个错误NoMethodError: undefined method 'render_to_string' for #<CreateExcelSheetWorker:0x007fbccf51db30>
我的worker类:
class CreateExcelSheetWorker
include Si
希望你做得很好。我完全按照手册创建了一个新应用程序,并尝试使用axlsx_rails Gem导出excel文件。这个手册看起来很好,很完整,但是当我点击line_to标签时,这个错误就会弹出。
ProductsController#index is missing a template for this request format and variant. request.formats: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"] request.variant: []
这是:
所以我使用这个gem axlsx_rails导出一些excel文件中的数据。但有时我会得到错误,如禁止字符的名称或名称超过31个字符大小。我不知道如何处理这些错误。所有我想要的是渲染索引再次,如果这样的错误发生,并显示一个闪光的消息。我当前的代码如下
Class CustomersController
def index
@customers = Customer.all
respond_to do |format|
format.html # index.html.erb
format.xls
format.xlsx
end
e
我第一次做这个升级,第一步就面临问题:
基本上,我想升级我的项目的rails版本,所以我更改了rails 5.2的Gemfile并尝试运行:
bundle update rails
作为给定的,但我无法更新包并得到以下错误
Bundler could not find compatible versions for gem "activerecord":
In Gemfile:
rails (~> 5.2) was resolved to 5.2.1.rc1, which depends on
activerecord (= 5.2.1.rc1)