3

I've a problem with the library apache poi, i want to copy the style of a cell and to do this i use the function cloneStyleFrom() and all works good except the copy of borders style. I don't understand if is my mistake or if this function doesn't implements the copy of the borders style.

This is my code:

int stHashCode = oldCell.getCellStyle().hashCode();
XSSFCellStyle newCellStyle = styleMap.get(stHashCode);
if (newCellStyle == null) {
    newCellStyle = newCell.getSheet().getWorkbook().createCellStyle();
    newCellStyle.cloneStyleFrom(oldCell.getCellStyle());
    styleMap.put(stHashCode, newCellStyle);
}
    newCell.setCellStyle(newCellStyle);

Someone can help me? Where is my mistake?

Thanks

JBerta93
  • 699
  • 3
  • 16
  • 27
  • What version of POI you're using? – Artem Shafranov Oct 20 '12 at 07:43
  • 1
    What's about the style of the "oldCell"? It was created programmatically, or it is contained in a workbook that was created with MS Excel? If it was created programmatically can you post that code? – Artem Shafranov Oct 22 '12 at 16:27
  • 1
    The oldCell is contained in a workbook that was created in MS Excel 2007. On the workbook that contains the old cell i read only. – JBerta93 Oct 23 '12 at 07:59
  • 2
    I also failed to clone style from one book to another. It seems like POI's bug. I think you should find a workaround, for example, try to copy style manually. – Artem Shafranov Oct 24 '12 at 13:00

0 Answers0