4

I searched around for this for awhile, so forgive me if there is an answer already. I am having trouble applying borders to merged cells using CFSpreadsheet. Below is some example code.

<cfscript>
newSS = SpreadsheetNew('Testing');      //Create Spreadsheet    

SpreadsheetMergeCells(newSS,1,1,1,9);
SpreadsheetAddRow(newSS,'Underline this Header');
SpreadSheetFormatCell(newSS,{bold=true,alignment='center',bottomborder='thin'},1,1);    

Spreadsheetwrite(newSS,expandpath('myTest.xls'),true);  //Write File
</cfscript>

What I would expect is the top cell to be underlined all the way across. What I get is the top cell only underlined through column "A" and not underlined after. Is there anyway around this or is this just a limitation of CFSpreadsheet??

Thanks!

vivasuzi
  • 75
  • 7

1 Answers1

2

According to the POI FAQ's, ie underlying library CF uses to generate spreadsheets, this is currently not supported (emphasis mine):

12. How do I add a border around a merged cell?

Add blank cells around where the cells normally would have been and set the borders individually for each cell. We will probably enhance HSSF in the future to make this process easier.

Probably the best you can do for now is to use SpreadsheetFormatCellRange instead of SpreadSheetFormatCell:

SpreadsheetFormatCellRange ( newSS
                , {bold=true,alignment='center',bottomborder='thin'}
                , 1,1,1,9 );
Leigh
  • 28,765
  • 10
  • 55
  • 103
  • Thank you! That worked! I hope they fix this in the future. My users want this spreadsheet to come out so specific that I was trying everything to get borders to show. The only weird thing is now the cells A-I are all really squished in this example, but I will work through that next :) – vivasuzi Mar 11 '16 at 12:40
  • 1
    BTW that POI Faqs link gave me an error - not found :( – vivasuzi Mar 11 '16 at 12:48
  • @vivasuzi - Thanks for the heads up about the links! Mangled links now fixed ;-) – Leigh Mar 11 '16 at 14:01
  • *now the cells A-I are all really squished in this example* Weird. Under CF11 the before and after cell size is the same. – Leigh Mar 12 '16 at 16:00
  • We are on CF 10. Wonder if that makes a difference. Thanks for your help! We are now looking at some other things b/c it seems this method is a ton of extra work. Since the formatted spreadsheet already exists, now we are trying some older methods we have used to just edit the data in the spreadsheet – vivasuzi Mar 14 '16 at 14:17