ColdFusion 9.0 Resources |
SpreadsheetMergeCellsSee alsoSpreadsheetGetCellComment, SpreadsheetFormatCell, SpreadsheetGetCellFormula, SpreadsheetGetCellValue, SpreadsheetSetCellComment, SpreadsheetSetCellFormula, SpreadsheetSetCellValue Parameters
UsageIf you merge two cells using this function, the merged cell by default displays the value in the cell that is on the left-hand side of the spreadsheet. For example, if you merge the cell (20,3) and cell (20,4), then the value in the cell (20, 3) is displayed. If the cell (20, 3) is blank, then after merging, the cell displays blank. ExampleThe following example merges cells 4-6 in rows 1-3 of an Excel spreadsheet object. It puts text in the merged cells and saves the sheet to a file so you can see the result. <cfscript> ///We need an absolute path, so get the current directory path. theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & "mergecells.xls"; //Create a new Excel spreadsheet object and add the query data. theSheet = SpreadsheetNew("CourseData"); //Merges cells 4-6 in the first three rows of the Excel spreadsheet object. SpreadsheetMergeCells(theSheet,1,3,4,6); //Set the value of the merged cell. SpreadsheetSetCellValue(theSheet,"Columns 4-6 of rows 1-3 are merged",1,4); </cfscript> <!--- Write the spreadsheet to a file, replacing any existing file. ---> <cfspreadsheet action="write" filename="#theFile#" name="theSheet" overwrite=true> |