coldfusionformattingcfspreadsheet

CFSpreadsheet borders for Merged Cells


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!


Solution

  • 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 );