Code Monkey home page Code Monkey logo

Comments (1)

thalesmiguel avatar thalesmiguel commented on May 24, 2024

I think I've found something!
As it is explained in the README file, the code used to generate the report is this:

def print
  .
  .
  .
  send_data report.generate, type: 'application/vnd.oasis.opendocument.text',
                              disposition: 'attachment',
                              filename: 'report.odt'
end

In my case, I need to open the generated file as soon as it is generated (no need to save it). To do so, I used this:

def print
  .
  .
  .
  path = "#{Rails.root}/app/reports/generated/report.odt"
  report.generate(path)
  `libreoffice #{path}`
  `rm -rf #{path}`
end

Explaining

First, I save the path to the file that will be generated (I've also created a folder in /app/reports called generated to organize the reports);
Then, I generate the report using report.generate(path);
To open this file on libreoffice, I'm calling `libreoffice #{path}`. It opens LibreOffice with the generated file.
To wrap it up, I call `rm -rf #{path}` to delete the report.

Notes

  1. Code on rb files inside `` is executed as command lines;
  2. This print action is inside my controller and there is a PUT route to it.

from odf-report.

Related Issues (20)

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.