How to output Excel and PDF using Excella

Install Excella

Specify exceller in build.gradle

dependencies {
  compile("org.bbreak.excella:excella-core:1.12")
  compile("org.bbreak.excella:excella-reports:1.11")
  compile("org.bbreak.excella:excella-trans:1.8")
}

Output Excel

Create Excel template

Create an Excel template by referring to the following http://excella-core.github.io/excella-core/reference/index.html http://excella-core.osdn.jp/excella-reports/reference/index.html

Java code

ExcellMakeService.java



      ReportBook outputBook = new ReportBook("C:\\templace\\template.xlsx", "./out", ExcelExporter.FORMAT_TYPE);

      ReportSheet outputSheet = new ReportSheet("report");
      outputBook.addReportSheet(outputSheet);

      //Describe the process to set the value to the variable defined in the template here.(abridgement)

      ReportProcessor reportProcessor = new ReportProcessor();
      try {
        reportProcessor.process(outputBook);
      } catch (Exception e) {
        e.printStackTrace();
      }

Output PDF

preparation of excella-pdf exporter

Since version 1.12 does not include exceller-pdf exporter, get the source from the following site. https://github.com/excella-core/excella-pdfexporter

Build by incorporating the source obtained from the above into the project.

Get Libre Office

Since Libre Office is used for conversion to PDF, download and install from the following https://ja.libreoffice.org/

Java code

Add code to ExcellMakeService.java above

ExcellMakeService.java



      System.setProperty("java.io.tmpdir", "/tmp/");
      //Set the path of the obtained Libre Office.
      System.setProperty("office.home", "C:\\Program Files\\LibreOffice");
      //ExcelExporter.FORMAT_TYPE to OoPdfExporter.FORMAT_Change to TYPE
      ReportBook outputBook = new ReportBook("C:\\templace\\template.xlsx", "./out", OoPdfExporter.FORMAT_TYPE);

      ReportSheet outputSheet = new ReportSheet("report");
      outputBook.addReportSheet(outputSheet);

      //Describe the process to set the value to the variable defined in the template here.(abridgement)

      ReportProcessor reportProcessor = new ReportProcessor();
      //Added OoPdfExporter to Exporter
      reportProcessor.addReportBookExporter(new OoPdfExporter());

      try {
        reportProcessor.process(outputBook);
      } catch (Exception e) {
        e.printStackTrace();
      }

Recommended Posts

How to output Excel and PDF using Excella
[Java] How to output and write files!
How to execute and mock methods using JUnit
[Java] How to get and output standard input
How to play audio and music using javascript
How to convert A to a and a to A using AND and OR in Java
Excel output using Apache POI!
How to authorize using graphql-ruby
How to test including images when using ActiveStorage and Faker
[Rails] Differences between redirect_to and render methods and how to output render methods
How to set and describe environment variables using Rails zsh
How to output array values without using a for statement
How to join a table without using DBFlute and sql
How to use StringBurrer and Arrays.toString.
How to use EventBus3 and ThreadMode
How to call classes and methods
How to use equality and equality (how to use equals)
common export to excel using poi
How to connect Heroku and Sequel
How to convert LocalDate and Timestamp
Output PDF and TIFF with Java 8
How to build CloudStack using Docker
How to POST JSON in Java-Method using OkHttp3 and method using HttpUrlConnection-
[Rails] How to upload images to AWS S3 using Carrierwave and fog-aws
[Rails] How to upload images to AWS S3 using refile and refile-s3
How to execute a contract using web3j
How to sort a List using Comparator
Enable log output to both file and console using log4j in Eclipse.
How to use OrientJS and OrientDB together
[Android] How to turn the Notification panel on and off using StatusBarManager
How to deploy to AWS using NUXTJS official S3 and CloudFront? With docker-compose
[Rails] How to upload images using Carrierwave
How to output Jetty log to any directory
How to realize hybrid search using morphological analysis and Ngram with Solr
[Java] How to calculate age using LocalDate
[Android] How to pass images and receive callbacks when sharing using ShareCompat
How to output Java string to console screen
How to set up and use kapt
How to record JFR (Java Flight Recorder) and output a dump file
How to build SquashTM and how to support Japanese
How to find the tens and ones
Output using methods and constants Learning memo
[Easy] How to upgrade Ruby and bundler
[Swift5] How to implement animation using "lottie-ios"
How to use substring and substr methods
How to implement image posting using rails
How to make asynchronous pagenations using Kaminari
Note: [Docker] How to start and stop
How to write and explain Dockerfile, docker-compose
[Rails] How to handle data using enum
How to use @Builder and @NoArgsConstructor together
How to insert icons using Font awesome
[Ruby] How to calculate the total amount using the initialize method and class variables
How to create an Excel form using a template file with Spring MVC
Sample to create PDF from Excel with Ruby
JDBC promises and examples of how to write
[Ruby] How to convert from lowercase to uppercase and from uppercase to lowercase
[Java] How to use FileReader class and BufferedReader class
(Memo) How to solve dummy output in Ubuntu 20.04
[Rails] How to create a graph using lazy_high_charts
How to color code console output in Eclipse