Whatever message this page gives is out now! Go check it out!
SpreadSheetSetColumnWidth (spreadhsheetobj, column number, width)Parameter | Description |
spreadsheetobj | The Excel spreadsheet object to which to set the column width. |
column number | Specifies the column to set the width. |
width | Specifies the width in points. Enter an integer value for the width. |
<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.xls";
// create spreadsheet object. Set xml to true as this is an xlsx file
mySheet=SpreadsheetNew("ColdFusion",false);
// Create another worksheet coldfusion1
SpreadsheetCreateSheet(mySheet,"ColdFusion1");
// Set headers for the xlsx file
SpreadSheetAddRow(mySheet,"Order,First Name,Last Name,Address,Amount,City");
SpreadSheetAddRows(mySheet,ArtOrders);
// set coldfusion as active sheet
SpreadsheetSetActiveSheet(mySheet,"ColdFusion1");
// new query for the new sheet
Artists=QueryExecute("Select * from APP.ARTISTS",[],{datasource="cfartgallery"});
SpreadSheetAddRow(mySheet,"ARTISTID,First Name,Last Name,Address,CITY,STATE,POSTALCODE,EMAIL,PHONE,FAX,THEPASSWORD");
SpreadSheetAddRows(mySheet,Artists);
// Define the structure for formatting a column
myFormat=StructNew();
myFormat.color="blue";
myFormat.bold=true;
myFormat.underline=true;
myFormat.alignment="center";
myFormat.font="Arial";
// Set the width of column 2 to 35 points
SpreadSheetSetColumnWidth(mySheet,2,35);
SpreadsheetWrite(mySheet,"#myFile#",true);
</cfscript>a=SpreadSheetNew(); SpreadSheetAddRow(a,"1,2,3,4,5,6,7,8"); SpreadSheetAddRow(a,"1,2,3,4,5,6,7,8",2,1); </cfscript> <cfset SpreadSheetSetColumnWidth(a,2,10)> <cfset SpreadSheetSetColumnWidth(a,3,25)> <cfspreadsheet action="write" filename="#expandpath('.')#/b.xls" name="a" overwrite="true"> |