簡體   English   中英

使用axlsx_rails在MS Excel中打開生成的文件的問題

[英]Issue with opening the generated file in MS Excel using axlsx_rails

我在Rails項目中使用axlsx_rails生成帶有驗證和下拉列表的excel文件。 生成文件后,我嘗試在MS Excel中打開文件,並說它需要修復文件,並且所有驗證和下拉菜單都已清除。

版本號

axlsx_rails - 0.1.5
axlsx - 1.3.6
rubyzip - 1.2.0
rails - 4.1.2
ruby - 2.2.2

@excel = Axlsx::Package.new
@excel.workbook.add_worksheet(name: "Samples") do |ws|
    ws.add_row @field_names
    sheet.add_data_validation("G2:G1000", {
       :type => :list,
       :formula1 => '"Jim", "Tom", "Jack"',
       :showDropDown => false,
       :showErrorMessage => true,
       :errorTitle => '',
       :error => 'Please use the dropdown selector to choose the value',
       :errorStyle => :stop,
       :showInputMessage => true,
       :prompt => 'Choose the value from the dropdown'})
    end
    @excel.serialize "tmp/SampleTemplate.xlsx"

使用發送文件

send_file "tmp/SampleTemplate.xlsx"

生成的文件在LibreOffice中工作,但在MSExcel中不工作

請幫忙

解決了。 問題就在這,

:formula_1 => '"Jim", "Tom","Jack"'

我已將其更改為

:formula_1 => '"Jim, Tom, Jack"'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM