https://bz.apache.org/bugzilla/show_bug.cgi?id=69366

            Bug ID: 69366
           Summary: CellUtil.setCellStyleProperties(Cell, Map<String,
                    Object>) doesn't found same styles sometimes
           Product: POI
           Version: 5.3.0-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: fjyoyd89f...@mail.ru
  Target Milestone: ---

I found out that CellUtil.setCellStyleProperties(Cell, Map<String, Object>)
doesn't found same styles sometimes. Especially when I set fillBackgroundColor
or fillForegroundColor property to null. It happens when setCellStyleProperties
calls getFormatProperties for already existed styles. Then getFormatProperties
calls XSSFCellStyle.getFillForegroundColor which return 64 instead of null.
Then styleMapsMatch says that these styles are different.

I suggest add some checks in setCellStyleProperties or styleMapsMatch. Or
prevent overwriting null to 64.

Hope you are ok with kotlin. Some code:
import org.apache.poi.ss.util.CellUtil.*
import org.apache.poi.xssf.usermodel.XSSFWorkbook

fun main() {
    val workbook = XSSFWorkbook()
    val sheet = workbook.createSheet()
    val properties = mapOf(
        FILL_FOREGROUND_COLOR to null,
        FILL_BACKGROUND_COLOR to null,
    )
    for (i in 0..1000) {
        val cell = getCell(getRow(0, sheet), i)
        setCellStyleProperties(cell, properties)
    }
    println(workbook.numCellStyles)
}

Expected: 2
Actually: 1002

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to