Comment Has Transparent Background Created with Apche poi XSSFWorkbook

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Comment Has Transparent Background Created with Apche poi XSSFWorkbook


I am trying to add comment in .xlsm excel template with Apache poi
XSSFWorkbook, but the comment always shows transparent background color.
Someone know how to manipulate XSSFWorkbook comment style? Apache poi:
v3.15; excel extension: .xlsm; OS: Mac

Here's what i found: The current template style might affect XSSFWorkbook
comment style, because the comment adding works well when i created a brand
new sheet or template....But i do need to add comment in the required
existing sheet.

import{CellRangeAddress, CellReference}
import org.apache.poi.util.Units
import org.apache.poi.xssf.usermodel._

         val file = WorkbookFactory.create("worksheet.xlsm")
    private def setComment(file: Workbook) : Workbook = {
          //get sheet
          val currentSheet = file.getSheet("Sheet1")
          val rowInfo = currentSheet.getRow(2)
          val cell = rowInfo.getCell(3)
          //begin adding comment
          val factory = file.getCreationHelper()
          val drawing = cell.getSheet.createDrawingPatriarch()
          //create comment box
          val anchor = factory.createClientAnchor()
          //locate comment
          anchor.setCol1(cell.getColumnIndex + 1 )
          anchor.setCol2(cell.getColumnIndex + 5 )
          anchor.setRow2(cell.getRowIndex + 4)
          val comment1 = drawing.createCellComment(anchor)
          val str = factory.createRichTextString("this is a comment")
expected result should be a normal yellow box comment when hovering over not
a transparent background comment

Sent from:

To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]