Files created by spreadsheet marked as virus

I use the Spreadsheet gem to create xls files and zip them for download using rubyzip gem in my application.

Below is a code snippet of my lib class that generates xls files

     excel_file = Spreadsheet::Workbook.new 
     sheet1 = excel_file.create_worksheet :name => 'Attendance'
     .#code
     .#code for xls
     .#code
     excel_file.write("/home/Code/attn/files/excel/TEST-#{@name}-#{t}.xls")

And I have a zip file like this in my controller

     files = Dir.glob("#{Rails.root}/files/excel/*.xls")
     @original_file = File.basename(files.first)
     @original_path = "#{Rails.root}/files/excel"

     Zip:: File.open(@filename, Zip::File::CREATE) do |z|
    z.add(@original_file,@original_path+'/'+@original_file)
    z.get_output_stream("Other details.txt") { |os| os.write "This is a system generated excel sheet" }
  end
send_file @filename, :type => 'application/zip', :filename => "Attendance-#{city}-#{t}.zip", :stream=> false, :x_sendfile=>true

This approach works very well when I download a zip file using the Ubuntu desktop and read the xls file using LibreOffice. The zip is extracted properly without any problems, and the xls sheet is read without any error warnings.

But when I download the same zip file in Windows 7 and unzip it using File Explorer, the xls file when opening with MS Excel "Error 0x80070057: parameters are incorrect", an error pops up.

, xls gmail hotmail, .

. - xls 140 ,

.

: -

Ubuntu 14.04 server
rvm 1.26.11
Ruby 2.2.2

Ubuntu 14.04
rvm 1.26.11
Ruby 2.1.6

: -

rubyzip (1.1.7)
spreadsheet (1.0.7)
rubygems-bundler (1.4.4)
ruby-ole (1.2.11.8)

rubyzip (1.1.7)
spreadsheet (1.0.7)
rubygems-update (2.4.8)
ruby-ole (1.2.11.8)

mime xls:

/CDFV2-; =

+4

Source: https://habr.com/ru/post/1621235/


All Articles