User Guide Cancel

spreadsheetGetColumnWidth

 

Description

Retrieves the width of a column in pixels. 

Returns

An integer representing the width of the specified column. 

History

  • ColdFusion (2025 release): Added the function. 

Syntax

spreadsheetGetColumnWidth(spreadSheetObject,column,returnWidthInPixels)
spreadsheetGetColumnWidth(spreadSheetObject,column,returnWidthInPixels)
spreadsheetGetColumnWidth(spreadSheetObject,column,returnWidthInPixels)

Parameters 

Name

 

 

Required

 

 

Type

 

 

Description

 

 

spreadSheetObject 

 

 

Yes 

 

 

ExcelInfo 

 

 

The Excel spreadsheet object in which to retrieve the width of the specified column.  

 

column 

 

 

Yes 

 

 

Integer 

 

 

The column number whose width is to be retrieved.  

 

returnWidthInPixels 

 

 

No 

 

 

Boolean 

 

 

True to return the width in number of pixels. If false, it will return width in points.  

 

Example 1- returnWidthInPixels=TRUE

<cfquery name="art" datasource="cfartgallery">
SELECT * FROM ART
</cfquery>
<cfscript>
theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & "art-col-width.xls";
// create a spreadsheet object
theSheet=spreadsheetNew("SampleData")
// add rows from the table to the spreadsheet
spreadsheetAddRows(theSheet,art)
// write the spreadsheet
spreadsheetWrite(theSheet,theFile,"yes")
// Whether to return the width in number of pixels.
// If false, it will return width in number of characters
// that can fit in column.
colWidth=spreadsheetGetColumnWidth(theSheet,3,"TRUE")
writeOutput(colWidth)
</cfscript>
<cfquery name="art" datasource="cfartgallery"> SELECT * FROM ART </cfquery> <cfscript> theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & "art-col-width.xls"; // create a spreadsheet object theSheet=spreadsheetNew("SampleData") // add rows from the table to the spreadsheet spreadsheetAddRows(theSheet,art) // write the spreadsheet spreadsheetWrite(theSheet,theFile,"yes") // Whether to return the width in number of pixels. // If false, it will return width in number of characters // that can fit in column. colWidth=spreadsheetGetColumnWidth(theSheet,3,"TRUE") writeOutput(colWidth) </cfscript>
<cfquery name="art" datasource="cfartgallery">
    SELECT * FROM ART
</cfquery>
<cfscript>
    theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & "art-col-width.xls";
    // create a spreadsheet object
    theSheet=spreadsheetNew("SampleData")
    // add rows from the table to the spreadsheet
    spreadsheetAddRows(theSheet,art)
    // write the spreadsheet
    spreadsheetWrite(theSheet,theFile,"yes")
    // Whether to return the width in number of pixels. 
    // If false, it will return width in number of characters 
    // that can fit in column.
    colWidth=spreadsheetGetColumnWidth(theSheet,3,"TRUE") 
    writeOutput(colWidth)
</cfscript>

Example 1- returnWidthInPixels=FALSE

<cfquery name="art" datasource="cfartgallery">
SELECT * FROM ART
</cfquery>
<cfscript>
theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & "art-col-width.xls";
// create a spreadsheet object
theSheet=spreadsheetNew("SampleData")
// add rows from the table to the spreadsheet
spreadsheetAddRows(theSheet,art)
// write the spreadsheet
spreadsheetWrite(theSheet,theFile,"yes")
// Whether to return the width in number of pixels.
// If false, it will return width in number of characters
// that can fit in column.
colWidth=spreadsheetGetColumnWidth(theSheet,3,"FALSE")
writeOutput(colWidth)
</cfscript>
<cfquery name="art" datasource="cfartgallery"> SELECT * FROM ART </cfquery> <cfscript> theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & "art-col-width.xls"; // create a spreadsheet object theSheet=spreadsheetNew("SampleData") // add rows from the table to the spreadsheet spreadsheetAddRows(theSheet,art) // write the spreadsheet spreadsheetWrite(theSheet,theFile,"yes") // Whether to return the width in number of pixels. // If false, it will return width in number of characters // that can fit in column. colWidth=spreadsheetGetColumnWidth(theSheet,3,"FALSE") writeOutput(colWidth) </cfscript>
<cfquery name="art" datasource="cfartgallery">
    SELECT * FROM ART
</cfquery>
<cfscript>
    theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & "art-col-width.xls";
    // create a spreadsheet object
    theSheet=spreadsheetNew("SampleData")
    // add rows from the table to the spreadsheet
    spreadsheetAddRows(theSheet,art)
    // write the spreadsheet
    spreadsheetWrite(theSheet,theFile,"yes")
    // Whether to return the width in number of pixels. 
    // If false, it will return width in number of characters 
    // that can fit in column.
    colWidth=spreadsheetGetColumnWidth(theSheet,3,"FALSE") 
    writeOutput(colWidth)
</cfscript>

Get help faster and easier

New user?