Bug 17494

Summary: probelem re: creating a cell with borders on a template that was read in
Product: POI Reporter: Stephen <stephen>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED WONTFIX    
Severity: major    
Priority: P3    
Version: 2.0-pre3   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Stephen 2003-02-27 15:45:16 UTC
In 1.5.1 final:
I read in an xls file that was previously created in Excel.
I add several cells with values, and then
I add several rows of cells that have a style with borders on three sides
(I am creating a table with bordered cells).
I am using a style repeatedly, which is created via this code:

private static void constructExcelShadedCellStyleAX()
{
excelShadedCellStyleAX = wb.createCellStyle();
HSSFFont f = wb.createFont();
f.setFontHeightInPoints((short) 10);
excelShadedCellStyleAX.setFont(f);
excelShadedCellStyleAX.setFillForegroundColor(HSSFColor.PALE_BLUE.index);
excelShadedCellStyleAX.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
excelShadedCellStyleAX.setBorderLeft(HSSFCellStyle.BORDER_THIN);
excelShadedCellStyleAX.setBorderRight(HSSFCellStyle.BORDER_THIN);
excelShadedCellStyleAX.setBorderBottom(HSSFCellStyle.BORDER_THIN);
}

After modifying the file, I write it out to an xls file.
Then I open it in Excel.
When I use a style WITHOUT BORDERS, it works fine.
When I use the above style, WITH BORDERS, when I open the
new Excel file, and put the cursor in any cell that touches
one of the cells where I have set the border, and then do
from the Excel menu:  Format...Cells
Nothing happens at all. I do NOT get the normal "Format Cells"
dialog box.  For other cells, it works normally. After
trying several cells, the Format...Cells function starts
to work properly -- except that it still does not work
for those cells directly above and directly below the cells
that were formatted with a border.
Comment 1 Stephen 2003-02-27 15:49:32 UTC
Omit the statement:
After trying several cells, the Format...Cells function starts
to work properly.
It does NOT start to work properly.
Comment 2 Andy Oliver 2003-07-24 15:53:59 UTC
Has this been fixed in the 2.0-pre2 release?  I think it was some time ago. 
Please let us know if it works with 2.0-pre2.
Comment 3 Avik Sengupta 2003-10-30 17:00:48 UTC
Can someone do a compilable testcase please? I dont understand this bug!!
Comment 4 Avik Sengupta 2003-10-30 17:01:30 UTC
Can someone do a compilable testcase please? I dont understand this bug!!
Comment 5 Avik Sengupta 2003-10-30 17:02:03 UTC
sorry, didnt mean to close bug
Comment 6 sty 2005-11-04 11:56:56 UTC
Just add a border to a cell using the usermodel, save the file
and open it with Excel (2000, or XP or whatever).

When you try to RightClick on the bordered cell to view
the cell format dialog it does not work.
The Cell format dialog does not appear at all.

Maybe are the biff codes for cell borders not well
written? It's a major flaw if you think the end user
may want to retouch manually the spreadsheet.
Comment 7 Carsten Wolters 2007-08-03 05:20:18 UTC
The bug is still active for POI-3.0.1-FINAL.

Just set a border style of a cell:


cell.getCellStyle().setBorderLeft(HSSFCellStyle.BORDER_THIN)


and the a right click on the bordered cell in Excel XP to view
the cell format dialog it does not work.
Comment 8 Yegor Kozlov 2007-08-03 06:05:53 UTC
You should set both border style and border color:

 style.setBorderTop(HSSFCellStyle.BORDER_THIN);
 style.setTopBorderColor(HSSFColor.BLACK.index);

This way it works fine for me.

Regards,
Yegor
Comment 9 Carsten Wolters 2007-08-03 06:25:42 UTC
As you mentioned, I tried the following:

 style.setBorderTop(HSSFCellStyle.BORDER_THIN);
 style.setTopBorderColor(HSSFColor.BLACK.index);

and it works.

But if I try to copy a color from a different cell style, the same problem occurs:

 style.setBorderTop(HSSFCellStyle.BORDER_THIN);
 style.setTopBorderColor(otherValidCellStyle.getTopBorderColor());

HSSFColor.BLACK.index = 8
otherValidCellStyle.getTopBorderColor() = 0

Setting the BorderColor to zero will result in the problem that the cell format
dialog does not appear anymore.
Comment 10 Yegor Kozlov 2007-08-03 06:34:48 UTC
zero is not valid color index.
If otherValidCellStyle.getTopBorderColor() returns 0 it means that
otherValidCellStyle does not have top border. But if you call
otherValidCellStyleWithTopBorder.getTopBorderColor() it should work. 

Regards,
Yegor