Why is a cloned HSSFCellStyle not equal to the style it was cloned from?
-
30-10-2019 - |
Вопрос
I am using one HSSF Workbook as a template for another. Because of how that works, as you probably know if you're reading this, I cannot simply take a cell from workbook 1 and set its style to the CellStyle from workbook 2. The way this is supposed to be done is to cloneStyleFrom the second style.
However, there is a maximum of 4000 styles in a worksheet so I am trying to avoid cloning an unlimited number of styles. So, I am checking to see if a the style I am about to clone is equal to any style that already exists in my workbook. If it is, I just use the style that already exists. If it isn't, I clone the style from the template workbook.
I'm using the equals method defined below, which doesn't seem to care what workbook the style comes from.
However, when at the end of all this I check:
if ( !getCellStyle().equals(cell.getCellStyle()) ) {
System.out.println("Not equal to cloned style!");
} else {
System.out.println("Equal to cloned style.");
}
... the output indicates that the styles are not equal.
Why is this?
Note: Verified that both objects are type HSSFCellStyle using instanceof.
Нет правильного решения