Whatever message this page gives is out now! Go check it out!

spreadsheetGetColumnWidth

Last update:
May 18, 2026

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)

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>
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>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page