randym / axlsx

xlsx generation with charts, images, automated column width, customizable styles and full schema validation. Axlsx excels at helping you generate beautiful Office Open XML Spreadsheet documents without having to understand the entire ECMA specification. Check out the README for some examples of how easy it is. Best of all, you can validate your xlsx file before serialization so you know for sure that anything generated is going to load on your client's machine.
MIT License
2.62k stars 696 forks source link

Error when opening xlsx file from OneDrive but not from other programs #667

Open jordizg07 opened 1 year ago

jordizg07 commented 1 year ago

Hello, I am trying to generate an xlsx file. When I generate it, I can open it with all software like LibreOffice Calc, but when I open it with OneDrive in Microsoft Office Excel, it gives me an error. I am using axlsx 2.0.1 and Ruby 2.7.1. Can someone help me?

The code I use (greatly simplified as a generic example) is this::

require 'axlsx'

Axlsx::Package.new do |p|
  p.use_shared_strings = true  # Asegúrate de que esta opción esté configurada
  p.use_autowidth = true  # Esta opción ajusta automáticamente el ancho de las columnas
  p.workbook.add_worksheet(name: 'Sheet1') do |sheet|
    sheet.add_row ['Name', 'Age', 'Gender']
    sheet.add_row ['name1', 'age1', 'gender1']
    sheet.add_row ['name2',' age2', 'gender2']
  end
  p.serialize('example.xlsx')
send_file 'example.xlsx'
end
straydogstudio commented 10 months ago

@jordizg07 You'll want to use https://github.com/caxlsx/caxlsx instead, which is where all maintenance is happening.