diff --git a/build.gradle.kts b/build.gradle.kts index 2894a75..821aee9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -36,8 +36,8 @@ dependencies { implementation("org.yaml:snakeyaml:2.2") implementation("io.minio:minio:8.5.7") implementation("org.apache.httpcomponents:httpclient:4.5.14") - implementation("org.apache.poi:poi:5.0.0") - implementation("org.apache.poi:poi-ooxml:5.0.0") + implementation("org.apache.poi:poi:5.2.3") + implementation("org.apache.poi:poi-ooxml:5.2.3") api ("net.cactusthorn.config:config-core:0.81") api ("net.cactusthorn.config:config-yaml:0.81") kapt("net.cactusthorn.config:config-compiler:0.81") diff --git a/src/main/kotlin/com/restapi/Main.kt b/src/main/kotlin/com/restapi/Main.kt index 6bed341..0c97abc 100644 --- a/src/main/kotlin/com/restapi/Main.kt +++ b/src/main/kotlin/com/restapi/Main.kt @@ -7,7 +7,6 @@ import com.restapi.config.Auth.validateAuthToken import com.restapi.controllers.* import com.restapi.domain.DataNotFoundException import com.restapi.domain.Product -import com.restapi.domain.Session import com.restapi.domain.Session.currentTenant import com.restapi.domain.Session.currentUser import com.restapi.domain.Session.objectMapper diff --git a/src/main/kotlin/com/restapi/controllers/Excel.kt b/src/main/kotlin/com/restapi/controllers/Excel.kt index d5c4851..91b1f41 100644 --- a/src/main/kotlin/com/restapi/controllers/Excel.kt +++ b/src/main/kotlin/com/restapi/controllers/Excel.kt @@ -1,9 +1,46 @@ package com.restapi.controllers -import java.io.FileOutputStream -enum class DataType { - QUOTE, PO, VENDOR +import com.restapi.domain.Product +import org.apache.poi.ss.usermodel.Cell +import org.apache.poi.ss.usermodel.Row +import org.apache.poi.ss.usermodel.WorkbookFactory +import org.apache.poi.xssf.usermodel.XSSFWorkbook +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream +import java.io.FileInputStream +import java.io.InputStream + +fun CreateExcel(productList: List): InputStream { + val wb = XSSFWorkbook() + val sh = wb.createSheet() + sh.createRow(0).createCell(0).setCellValue("Name") + sh.createRow(0).createCell(1).setCellValue("Description") + sh.createRow(0).createCell(2).setCellValue("HSN") + sh.createRow(0).createCell(3).setCellValue("UOM") + + var rowNum = 1 + for (product in productList) { + val row: Row = sh.createRow(rowNum++) + + row.createCell(0).setCellValue(product.name) + row.createCell(1).setCellValue(product.description) + row.createCell(2).setCellValue(product.hsnCode) + + val uomCell: Cell = row.createCell(3) + uomCell.setCellValue(product.uom?.name ?: "") + } + + val baos = ByteArrayOutputStream() + wb.write(baos) + wb.close() + + return ByteArrayInputStream(baos.toByteArray()) + } -fun CreateExcel(cols :List, excelFor :DataType) { - //val wb = HSSFWorkbook() + +fun ExcelRead(filename: String){ + val inputStream = FileInputStream("./${filename}.xlsx") + val workbook = WorkbookFactory.create(inputStream) + val workSheet = workbook.getSheetAt(0) + } \ No newline at end of file diff --git a/src/main/kotlin/com/restapi/domain/models.kt b/src/main/kotlin/com/restapi/domain/models.kt index 2753361..a9258b6 100644 --- a/src/main/kotlin/com/restapi/domain/models.kt +++ b/src/main/kotlin/com/restapi/domain/models.kt @@ -9,6 +9,7 @@ import io.ebean.annotation.* import io.ebean.annotation.Index import java.time.LocalDate import java.time.LocalDateTime +import java.util.* import javax.persistence.* data class Comments(val text: String = "", val by: String = "", val at: LocalDateTime = LocalDateTime.now())