<
http://apache-poi.1045710.n5.nabble.com/file/t340693/Screen_Shot_2019-05-31_at_2.png>
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 org.apache.poi.ss.usermodel.ClientAnchor.AnchorType
import org.apache.poi.ss.usermodel._
import org.apache.poi.ss.util.{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.setRow1(cell.getRowIndex+1)
anchor.setCol2(cell.getColumnIndex + 5 )
anchor.setRow2(cell.getRowIndex + 4)
val comment1 = drawing.createCellComment(anchor)
val str = factory.createRichTextString("this is a comment")
comment1.setString(str)
cell.setCellComment(comment1)
file
}
expected result should be a normal yellow box comment when hovering over not
a transparent background comment
--
Sent from:
http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html---------------------------------------------------------------------
To unsubscribe, e-mail:
[hidden email]
For additional commands, e-mail:
[hidden email]