Skip to content

Commit

Permalink
πŸ”€ :: excel 간격 λ³€κ²½ 및 μƒλ²Œμ  단계 μΆ”κ°€
Browse files Browse the repository at this point in the history
  • Loading branch information
lyutvs committed Mar 30, 2023
1 parent 2ef4cc6 commit 4609279
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ExcelSpiImpl(
) : ExcelSpi {

override suspend fun writeUserPointHistoryExcelFile(): ByteArray {
val attributes = listOf("ν•™λ²ˆ", "이름", "상점", "벌점", "상점내역", "λ²Œμ λ‚΄μ—­", "ꡐ윑 단계")
val attributes = listOf("ν•™λ²ˆ", "이름", "상점", "벌점", "상점내역", "λ²Œμ λ‚΄μ—­", "ꡐ윑 단계", "ꡐ윑 ν•„μš” μ—¬λΆ€")
val pointStatus = pointStatusSpi.findAll()
val userPointStatus = userSpi.getStudent()
val goodPointHistories = pointHistorySpi.findAllByType(true)
Expand All @@ -44,12 +44,18 @@ class ExcelSpiImpl(
userStatus.badPoint.toString(),
goodPointHistoryString.replace(Regex("[\\[\\]]"), ""),
badPointHistoryString.replace(Regex("[\\[\\]]"), ""),
userStatus.penaltyLevel.toString(),
convertPenaltyRequiredToString(userStatus.isPenaltyRequired),
)
}.sortedBy { it[0] } // ν•™λ²ˆμˆœμœΌλ‘œ μ •λ ¬

return createExcelSheet(attributes, userData, "학생 μƒλ²Œμ  λ‚΄μ—­")
}

private fun convertPenaltyRequiredToString(isPenaltyRequired: Boolean): String {
return if (isPenaltyRequired) "ν•„μš”" else "ν•„μš” μ—†μŒ"
}

private fun createExcelSheet(
attributes: List<String>,
dataList: List<List<Any>>,
Expand All @@ -70,8 +76,9 @@ class ExcelSpiImpl(
sheet.setColumnWidth(1, 7 * 256)
sheet.setColumnWidth(2, 5 * 256)
sheet.setColumnWidth(3, 5 * 256)
sheet.setColumnWidth(4, 37 * 256)
sheet.setColumnWidth(5, 37 * 256)
sheet.setColumnWidth(4, 45 * 256)
sheet.setColumnWidth(5, 45 * 256)
sheet.setColumnWidth(6, 10 * 256)

ByteArrayOutputStream().use { stream ->
workbook.write(stream)
Expand Down

0 comments on commit 4609279

Please sign in to comment.