save file changes
This commit is contained in:
parent
141d8961e4
commit
fc361e3133
@ -1,25 +1,13 @@
|
|||||||
package com.restapi.controllers
|
package com.restapi.controllers
|
||||||
|
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.restapi.domain.*
|
import com.restapi.domain.*
|
||||||
import com.restapi.domain.Document
|
|
||||||
import com.restapi.domain.PurchaseOrder
|
|
||||||
import com.restapi.domain.Quotation
|
|
||||||
import com.restapi.domain.Session.currentUser
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFSheet
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook
|
|
||||||
import com.restapi.domain.Session.database
|
|
||||||
import com.restapi.domain.Vendor
|
|
||||||
import org.apache.poi.hssf.usermodel.DVConstraint
|
import org.apache.poi.hssf.usermodel.DVConstraint
|
||||||
import org.apache.poi.hssf.usermodel.HSSFDataValidation
|
import org.apache.poi.hssf.usermodel.HSSFDataValidation
|
||||||
import org.apache.poi.ss.usermodel.Cell
|
import org.apache.poi.hssf.usermodel.HSSFSheet
|
||||||
import org.apache.poi.ss.usermodel.CellType
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook
|
||||||
import org.apache.poi.ss.usermodel.DateUtil
|
import org.apache.poi.ss.usermodel.*
|
||||||
import org.apache.poi.ss.usermodel.Workbook
|
|
||||||
import org.apache.poi.ss.usermodel.WorkbookFactory
|
|
||||||
import org.apache.poi.ss.util.CellRangeAddressList
|
import org.apache.poi.ss.util.CellRangeAddressList
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
@ -103,8 +91,13 @@ enum class EnumFor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun saveExcelFileLocally(fileName: String, wb: Workbook) {
|
fun saveExcelFileLocally(fileName: String, wb: Workbook) {
|
||||||
val path = "./excel/"
|
val path = "./excel"
|
||||||
val out = FileOutputStream(path + fileName)
|
val file = File(path, fileName)
|
||||||
|
|
||||||
|
if (!file.parentFile.exists()) {
|
||||||
|
file.parentFile.mkdirs()
|
||||||
|
}
|
||||||
|
val out = FileOutputStream(file)
|
||||||
wb.use {
|
wb.use {
|
||||||
it.write(out)
|
it.write(out)
|
||||||
}
|
}
|
||||||
@ -157,14 +150,7 @@ fun TemplateExcelFile(fileType: FileType) {
|
|||||||
|
|
||||||
FileType.VENDORS -> {
|
FileType.VENDORS -> {
|
||||||
val headers: List<String> = listOf(
|
val headers: List<String> = listOf(
|
||||||
"Name",
|
"Name", "MSME", "GST Number", "Address", "Rating", "Contact Name", "Contact Email", "Contact Mobile"
|
||||||
"MSME",
|
|
||||||
"GST Number",
|
|
||||||
"Address",
|
|
||||||
"Rating",
|
|
||||||
"Contact Name",
|
|
||||||
"Contact Email",
|
|
||||||
"Contact Mobile"
|
|
||||||
)
|
)
|
||||||
val wb = HSSFWorkbook()
|
val wb = HSSFWorkbook()
|
||||||
val sh = wb.createSheet()
|
val sh = wb.createSheet()
|
||||||
@ -179,8 +165,7 @@ fun TemplateExcelFile(fileType: FileType) {
|
|||||||
createHeaderRow(headers, sh, wb)
|
createHeaderRow(headers, sh, wb)
|
||||||
val r0 = CellRangeAddressList(0, 1000, 4, 4)
|
val r0 = CellRangeAddressList(0, 1000, 4, 4)
|
||||||
val dv0 = HSSFDataValidation(
|
val dv0 = HSSFDataValidation(
|
||||||
r0,
|
r0, DVConstraint.createExplicitListConstraint(arrayOf("LTR", "MTR", "NOS", "ALL"))
|
||||||
DVConstraint.createExplicitListConstraint(arrayOf("LTR", "MTR", "NOS", "ALL"))
|
|
||||||
).apply {
|
).apply {
|
||||||
suppressDropDownArrow = true
|
suppressDropDownArrow = true
|
||||||
}
|
}
|
||||||
@ -245,18 +230,9 @@ fun exportVendors(vendors: List<Vendor>) {
|
|||||||
val wb = HSSFWorkbook()
|
val wb = HSSFWorkbook()
|
||||||
val sh = wb.createSheet()
|
val sh = wb.createSheet()
|
||||||
|
|
||||||
val headers: List<String> =
|
val headers: List<String> = listOf(
|
||||||
listOf(
|
"No.", "Name", "MSME", "GST Number", "Address", "Rating", "Contact Name", "Contact Email", "Contact Mobile"
|
||||||
"No.",
|
)
|
||||||
"Name",
|
|
||||||
"MSME",
|
|
||||||
"GST Number",
|
|
||||||
"Address",
|
|
||||||
"Rating",
|
|
||||||
"Contact Name",
|
|
||||||
"Contact Email",
|
|
||||||
"Contact Mobile"
|
|
||||||
)
|
|
||||||
createHeaderRow(headers, sh, wb)
|
createHeaderRow(headers, sh, wb)
|
||||||
|
|
||||||
val totalCols = headers.size
|
val totalCols = headers.size
|
||||||
@ -455,17 +431,7 @@ fun exportInvoices(invoices: List<Invoice>) {
|
|||||||
val sh = wb.createSheet()
|
val sh = wb.createSheet()
|
||||||
|
|
||||||
val headers: List<String> = listOf(
|
val headers: List<String> = listOf(
|
||||||
"Number",
|
"Number", "Date", "Reference PO", "Status", "Vendor Name", "Vendor Address", "Product Id", "Product Name", "Unit Price", "Quantity", "Total Amount"
|
||||||
"Date",
|
|
||||||
"Reference PO",
|
|
||||||
"Status",
|
|
||||||
"Vendor Name",
|
|
||||||
"Vendor Address",
|
|
||||||
"Product Id",
|
|
||||||
"Product Name",
|
|
||||||
"Unit Price",
|
|
||||||
"Quantity",
|
|
||||||
"Total Amount"
|
|
||||||
)
|
)
|
||||||
createHeaderRow(headers, sh, wb)
|
createHeaderRow(headers, sh, wb)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user