Code Monkey home page Code Monkey logo

Comments (4)

tapajos avatar tapajos commented on August 21, 2024

I didn't submit a PR adding this code yet but I have something that may be helpful for you.

module Excelinator
  def self.array_to_xls(array)
    book = Spreadsheet::Workbook.new
    sheet = book.create_worksheet
    array.each_with_index do |row_data, index|
      row = sheet.row(index)
      row_data.each_with_index do |cell_data, row_index|
        if cell_data.kind_of?(Date)
          row.set_format row_index, Spreadsheet::Format.new(:number_format => 'MM/DD/YYYY')
        end
        row.push(cell_data)
      end
    end
    content = ''
    ios = StringIO.new(content)
    book.write(ios)
    content
  end
end

from excelinator.

facundofarias avatar facundofarias commented on August 21, 2024

Hey, yes! It's seems to be the feature that I need.
How can I integrate this code with the Excelinator I am using? By cloning the repo? Would this feature be enabled in the future? Thanks a lot!

from excelinator.

tapajos avatar tapajos commented on August 21, 2024

I'm planning submit a PR adding something like that but it needs to be improved to work with other types.

To be honest, you don't need Excelinator for that, you can use https://github.com/zdavatz/spreadsheet directly (if you don't need anything else from Excelinator).

from excelinator.

chrismo avatar chrismo commented on August 21, 2024

Yeah, Excelinator is just a little bit of glue code.

from excelinator.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.