Search code examples
kotlindesktop-application

How to read/write data from an excel file using kotlin in jetpack compose for desktop


How can I get/write data from a xlsx or xls file in a compose for desktop app using Kotlin ? I've found this link showing how to use it using Kotlin but I'm confused as to where do I put the below dependency code as I don't see any pom.xml file in my compose for desktop app project structure.

 <dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>${apache.poi.version}</version>
</dependency>

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>${apache.poi.version}</version>
</dependency>

I know this question might come across silly but I'm totally new to this.

Thanks


Solution

  • Okay, so if you use Compose Multiplatform Project - You probably using Gradle

    You have to find build.gradle (or build.gradle.kts ) file in the project root

    And there you have to add dependencies in the corresponding section.

    dependencies {
        implementation("org.apache.poi:poi:5.2.3")
        implementation("org.apache.poi:poi-ooxml:5.2.3")
    }
    

    Take a look at few examples, or videos about Gradle because you gonna use it every day in your programming life)

    Example screenshot

    enter image description here