Kotlin Spring Boot RestAPIs – Download Excel File – Apache POI + MySQL
Tags: kotlin, springboot, restapi, apachepoi
Published: 2021-04-18 16:09:00

https://grokonez.com/spring-framework/spring-boot/kotlin-spring-boot/kotlin-spring-boot-restapis-download-excel-file-apache-poi-mysql

Kotlin Spring Boot RestAPIs – Download Excel File – Apache POI + MySQL

In the tutorial, we show you how to create a Kotlin SpringBoot RestAPIs application that uses Spring JPA to get data from MySQL records and uses Apache POI library to write data to a Excel file.

Related posts:
- <a href="https://grokonez.com/kotlin/kotlin-read-write-excel-file-apache-poi-example">Kotlin – How to read/write Excel file with Apache POI</a>
- <a href="https://grokonez.com/java-integration/use-spring-jpa-mysql-spring-boot">How to use Spring JPA MySQL | Spring Boot</a>
- <a href="https://grokonez.com/spring-framework/spring-boot/multipartfile-create-spring-ajax-multipartfile-application-downloadupload-files-springboot-jquery-ajax-bootstrap">SpringBoot – Upload/Download MultipartFile to FileSystem – Bootstrap 4 + JQuery Ajax</a>

<!--more-->
<h2>Technologies</h2>
– Kotlin Spring Boot – 2.0.6.RELEASE
– Spring JPA
– MySQL
– Apache POI
<h2>Practice</h2>
Project Structure ->

<img src="https://grokonez.com/wp-content/uploads/2018/10/kotlin-spring-boot-restapi-download-excel-file-spring-jpa-mysql-project-structure.png" alt="kotlin-spring-boot-restapi-download-excel-file-spring-jpa-mysql-project-structure" width="352" height="472" class="alignnone size-full wp-image-15345" />
<h3>Create Kotlin SpringBoot project</h3>
Use SpringToolSuite to create a Kotlin SpringBoot project with below dependencies:

<pre><code class="language-html">&lt;dependency&gt;
	&lt;groupId&gt;org.jetbrains.kotlin&lt;/groupId&gt;
	&lt;artifactId&gt;kotlin-stdlib-jdk8&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
	&lt;groupId&gt;org.jetbrains.kotlin&lt;/groupId&gt;
	&lt;artifactId&gt;kotlin-reflect&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
	&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
	&lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;
&lt;/dependency&gt;               
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;      
&lt;dependency&gt;
	&lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
	&lt;artifactId&gt;poi-ooxml&lt;/artifactId&gt;
	&lt;version&gt;3.17&lt;/version&gt;
&lt;/dependency&gt;   
&lt;dependency&gt;
    &lt;groupId&gt;mysql&lt;/groupId&gt;
    &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;
    &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;
    &lt;version&gt;2.3.0&lt;/version&gt;
&lt;/dependency&gt;</code></pre>
<h3>Customer Model</h3>
– <code>Customer.kt</code> ->

More at:

https://grokonez.com/spring-framework/spring-boot/kotlin-spring-boot/kotlin-spring-boot-restapis-download-excel-file-apache-poi-mysql

Kotlin Spring Boot RestAPIs – Download Excel File – Apache POI + MySQL