Skip to content

Commit 11f85af

Browse files
committed
Try to fix non ASCII character
1 parent de45df5 commit 11f85af

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ More infos about this file : http://keepachangelog.com/
66

77
## [Unreleased] - no_due_date
88

9+
- **Try to fix non ASCII character**
10+
911
## [v1.0.2] - 2019.04.10
1012

1113
- **Fix memory leak: Resources should be correctly closed**

core/src/main/scala/com/colisweb/jruby/concurrent/constant/memory/excel/ConcurrentConstantMemoryExcel.scala

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook
1717
import scala.annotation.switch
1818
import scala.collection.immutable.SortedSet
1919
import scala.collection.mutable.ListBuffer
20+
import org.apache.poi.common.usermodel.fonts.FontCharset
2021

2122
sealed abstract class Cell extends Product with Serializable
2223
object Cell {
@@ -115,6 +116,13 @@ object ConcurrentConstantMemoryExcel {
115116
headerStyle.setAlignment(HorizontalAlignment.CENTER)
116117
headerStyle.setFont(boldFont)
117118

119+
val stringCellFont = wb.createFont()
120+
stringCellFont.setBold(false)
121+
stringCellFont.setCharSet(FontCharset.ANSI.getNativeId)
122+
123+
val stringCellStyle = wb.createCellStyle()
124+
stringCellStyle.setFont(stringCellFont)
125+
118126
val header = sheet.createRow(0)
119127
for ((celldata, cellIndex) <- cms.headerData.zipWithIndex) {
120128
val cell = header.createCell(cellIndex, CellType.STRING)
@@ -134,8 +142,11 @@ object ConcurrentConstantMemoryExcel {
134142
for ((cellData, cellIndex) <- rowData.zipWithIndex) {
135143
cellData match {
136144
case Cell.BlankCell => row.createCell(cellIndex, CellType.BLANK)
137-
case Cell.StringCell(value) => row.createCell(cellIndex, CellType.STRING).setCellValue(value)
138145
case Cell.NumericCell(value) => row.createCell(cellIndex, CellType.NUMERIC).setCellValue(value)
146+
case Cell.StringCell(value) =>
147+
val cell = row.createCell(cellIndex, CellType.STRING)
148+
cell.setCellStyle(stringCellStyle)
149+
cell.setCellValue(value)
139150
}
140151
}
141152
}

0 commit comments

Comments
 (0)