Excel R/W
This commit is contained in:
parent
438daacdc6
commit
8745db2127
@ -36,8 +36,8 @@ dependencies {
|
|||||||
implementation("org.yaml:snakeyaml:2.2")
|
implementation("org.yaml:snakeyaml:2.2")
|
||||||
implementation("io.minio:minio:8.5.7")
|
implementation("io.minio:minio:8.5.7")
|
||||||
implementation("org.apache.httpcomponents:httpclient:4.5.14")
|
implementation("org.apache.httpcomponents:httpclient:4.5.14")
|
||||||
implementation("org.apache.poi:poi:5.0.0")
|
implementation("org.apache.poi:poi:5.2.3")
|
||||||
implementation("org.apache.poi:poi-ooxml:5.0.0")
|
implementation("org.apache.poi:poi-ooxml:5.2.3")
|
||||||
api ("net.cactusthorn.config:config-core:0.81")
|
api ("net.cactusthorn.config:config-core:0.81")
|
||||||
api ("net.cactusthorn.config:config-yaml:0.81")
|
api ("net.cactusthorn.config:config-yaml:0.81")
|
||||||
kapt("net.cactusthorn.config:config-compiler:0.81")
|
kapt("net.cactusthorn.config:config-compiler:0.81")
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import com.restapi.config.Auth.validateAuthToken
|
|||||||
import com.restapi.controllers.*
|
import com.restapi.controllers.*
|
||||||
import com.restapi.domain.DataNotFoundException
|
import com.restapi.domain.DataNotFoundException
|
||||||
import com.restapi.domain.Product
|
import com.restapi.domain.Product
|
||||||
import com.restapi.domain.Session
|
|
||||||
import com.restapi.domain.Session.currentTenant
|
import com.restapi.domain.Session.currentTenant
|
||||||
import com.restapi.domain.Session.currentUser
|
import com.restapi.domain.Session.currentUser
|
||||||
import com.restapi.domain.Session.objectMapper
|
import com.restapi.domain.Session.objectMapper
|
||||||
|
|||||||
@ -1,9 +1,46 @@
|
|||||||
package com.restapi.controllers
|
package com.restapi.controllers
|
||||||
|
|
||||||
import java.io.FileOutputStream
|
import com.restapi.domain.Product
|
||||||
enum class DataType {
|
import org.apache.poi.ss.usermodel.Cell
|
||||||
QUOTE, PO, VENDOR
|
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<Product>): 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<String>, excelFor :DataType) {
|
|
||||||
//val wb = HSSFWorkbook()
|
fun ExcelRead(filename: String){
|
||||||
|
val inputStream = FileInputStream("./${filename}.xlsx")
|
||||||
|
val workbook = WorkbookFactory.create(inputStream)
|
||||||
|
val workSheet = workbook.getSheetAt(0)
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -9,6 +9,7 @@ import io.ebean.annotation.*
|
|||||||
import io.ebean.annotation.Index
|
import io.ebean.annotation.Index
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
import java.util.*
|
||||||
import javax.persistence.*
|
import javax.persistence.*
|
||||||
|
|
||||||
data class Comments(val text: String = "", val by: String = "", val at: LocalDateTime = LocalDateTime.now())
|
data class Comments(val text: String = "", val by: String = "", val at: LocalDateTime = LocalDateTime.now())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user