def createFirst(fullName: String, provinceLists: List[String], detailLists: List[List[String]]): String = {
var fileName = "fail"
try {
val filePath = "/a/test.xlsx"
val fs = new FileInputStream(filePath)
val wb: XSSFWorkbook = new XSSFWorkbook(fs)
val sheet = wb.getSheetAt(0)
val firstRow = sheet.createRow(0)
var index = 0
detailLists.map {
areaRow => {
val newRow = sheet.createRow(index)
var i: Int = 0
areaRow.map {
areaColumn =>
newRow.createCell(i).setCellValue(areaColumn)
i = i + 1
}
index = index + 1
}
}
val newFilePath = "/a/test2.xlsx"
val exportFile = new File(newFilePath)
if (!exportFile.getParentFile.exists())
exportFile.getParentFile.mkdirs
if (!exportFile.exists())
exportFile.createNewFile
val out = new FileOutputStream(exportFile)
out.flush()
wb.write(out)
out.close()
if (exportFile.exists && exportFile.length() > 0)
fileName = exportFile.getPath
} catch {
case e: Exception => {
log.error(s"JdbcExport Error:${e}+++${e.getStackTrace}+++++${e.getStackTraceString}++++${e.printStackTrace()}")
}
}
fileName
}
var fileName = "fail"
try {
val filePath = "/a/test.xlsx"
val fs = new FileInputStream(filePath)
val wb: XSSFWorkbook = new XSSFWorkbook(fs)
val sheet = wb.getSheetAt(0)
val firstRow = sheet.createRow(0)
var index = 0
detailLists.map {
areaRow => {
val newRow = sheet.createRow(index)
var i: Int = 0
areaRow.map {
areaColumn =>
newRow.createCell(i).setCellValue(areaColumn)
i = i + 1
}
index = index + 1
}
}
val newFilePath = "/a/test2.xlsx"
val exportFile = new File(newFilePath)
if (!exportFile.getParentFile.exists())
exportFile.getParentFile.mkdirs
if (!exportFile.exists())
exportFile.createNewFile
val out = new FileOutputStream(exportFile)
out.flush()
wb.write(out)
out.close()
if (exportFile.exists && exportFile.length() > 0)
fileName = exportFile.getPath
} catch {
case e: Exception => {
log.error(s"JdbcExport Error:${e}+++${e.getStackTrace}+++++${e.getStackTraceString}++++${e.printStackTrace()}")
}
}
fileName
}