Hello MSB, Thannks for quick answer, but I still run into the next problem.
Provided that I want to set cell color for a cell, then I: cellStyle = workbook.createCellStyle(); ... Cell.setCellStyle(cellStyle); And latter, I want to change the color for that cell, I get back the cellstyle object that created before and change it's properties: cellStyle = cell.getCellStyle(); .... The problem is that for some cell(blank cells), getCellStyle() return the default cellstyle that are shared with many cells on workbook. Changing this will affect so many another cells that I don't' want to. How can we handle this? Thanks -----Original Message----- From: MSB [mailto:[email protected]] Sent: Monday, August 17, 2009 12:37 PM To: [email protected] Subject: RE: How to set different types of fomat and style to different cell Yes, but would this not be the case if you did exactly the same with Excel itself? If not, I cannot imagine how the file would be structured; the style information has to be stored somewhere even if it is only the differences from a notaional 'base' style that are stored. Yours Mark B Khanh Tran-3 wrote: > > Hello, > > What if I programmatically format 500 cells with difference styles? > > The target spreadsheet now contains huge number of styles. > > Khanh > > -----Original Message---- > > > > A cellstyle can be "shared" by many cells in a workbook. Currently you are > > modifying the "shared" cellstyle, and this affects all cells that use that > > style. > > > > Instead, try to create a new style using HSSFWorkbook.createCellStyle(), > and > > then use cell.setCellStyle(HSSFCellStyle). > > > > In other words, replace: > > > > HSSFCellStyle cellStyle = cell.getCellStyle(); > > > > with: > > > > HSSFCellStyle cellStyle = workbook.createCellStyle(); > > cell.setCellStyle(cellStyle); > > > > - Rob > > > -- View this message in context: http://www.nabble.com/RE%3A-How-to-set-different-types-of-fomat-and-style-to -different-cell-tp25000554p25001251.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
