Whatever message this page gives is out now! Go check it out!
SpreadsheetMergeCells (spreadsheetObj, startRow, endRow, startColumn, endColumn)Parameter | Description |
spreadsheetObj | The Excel spreadsheet object containing the cells to merge. |
startRow | The number of the first row to merge. |
endRow | The row number of the last row to merge. |
startColumn | The column number of the first cell to merge. |
endColumn | The column number of the last cell to merge. |
<cfscript>
ArtOrders=QueryExecute("SELECT orderid,customerfirstname,customerlastname,address,total,city FROM orders
ORDER BY orderid",[],{datasource="cfartgallery"});
// Set the file path in the same location as this cfm
myFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & "myexcelfile.xlsx";
// Create spreadsheet object. Set xml to true as this is an xlsx file
mySheet=SpreadsheetNew("ColdFusion",true);
// Set headers for the xlsx file
SpreadSheetAddRow(mySheet,"Order,First Name,Last Name,Address,Amount,City");
SpreadSheetAddRows(mySheet,ArtOrders);
// Merge cells between rows 7-14 and cols 2-5
SpreadsheetMergeCells(mySheet,7,14,2,5);
SpreadsheetWrite(mySheet,"#myFile#",true);
</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> |