Thanks for letting me know. I also did a bit more digging and found the HSSFRegionUtil class. It may not be too much help to you as your merged range only encompasses two cells but if it were larger, HSSFRegionUtil may be of some help.
Maurya, Dilip wrote: > > Thanks MSB for the response. This is what worked for me: > Step 1) Create the cell. Add data and style to it. > Step 2) Merge it to the other cell. > Step 3) On the other cell apply same style. > > Thanks & Regards, > Dilip > > -----Original Message----- > From: MSB [mailto:[email protected]] > Sent: Wednesday, April 29, 2009 2:25 AM > To: [email protected] > Subject: Re: Merged Cells. > > > The exact same thing happens with Excel as well - the border was the > only > formatting not preserved after I merged the cells - and the only > suggestion > I can make is to delay setting the cells style until after you have > merged > the cells together. Browsing through the javadocs, I cannot see anything > that makes it possible to set the style on a merged region and I am > hoping > that if you create the cells, add the data to the first, merge the cells > together and then set the style object on that first cell following the > merge operation then HSSF/XSSF will interpret this as being applied to > the > merged region - hoping! > > Sorry to say I cannot test this hypothesis myself before leaving for > work > today. > > > Maurya, Dilip wrote: >> >> I have 2 cells in a sheet one below other. One cell has some data with >> style applied; the other cell has neither data nor any style. Cells > are >> then merged using: >> >> sheet.addMergedRegion(new CellRangeAddress(1,2,2,2)); >> >> >> >> The cells get merged and data is shown correctly, but the styles are >> semi-merged. In the sense that foreground color, font and font color > are >> applied but borders are not. The lower half of the merged cell still >> retains the borders. Check the image attached. >> >> >> >> Thanks, >> >> Dilip >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> > > -- > View this message in context: > http://www.nabble.com/Merged-Cells.-tp23283423p23291257.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] > > > -- View this message in context: http://www.nabble.com/Merged-Cells.-tp23283423p23314207.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]
