We help IT Professionals succeed at work.

Setting a column witdth in ColdFusion And POI Generated Excel Document

Tpaul_10
Tpaul_10 asked
on
Experts,

I need to set column witdth in  ColdFusion And POI Generated Excel Document. Following is the code I have been using based on one of posts before which was answered by AGX.
Please let me know how I can do it.

Here is the link
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Cold_Fusion_Markup_Language/Q_27362081.html
<cfquery name="qOne" datasource="cfdocexamples">
    SELECT CORNUMBER,DEPT_ID,COURSE_ID,CORNAME 
    FROM COURSELIST 
</cfquery> 

<CFSET FILE_TEMPLATE = "c:\testTemplate.xls">
<cfset workbook = SpreadSheetRead(FILE_TEMPLATE)>

<cfset SpreadsheetSetActiveSheet(workbook, "First Sheet")>
<cfset SpreadSheetAddRows(workbook, qOne, 1, 1, false ) />      
<cfspreadsheet action="write" filename="c:\output.xls" name="workbook" overwrite="true" />

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2015
Commented:
Use SpreadSheetSetColumnWidth just before you write to disk:

....
<cfset SpreadSheetAddRows(workbook, qOne, 1, 1, false ) />    
<!--- sets the first column's width (ie ColumnA) --->
<cfset SpreadSheetSetColumnWidth(workbook, 1, 75) />      
<cfspreadsheet action="write" filename="c:\output.xls" name="workbook" overwrite="true" />

Explore More ContentExplore courses, solutions, and other research materials related to this topic.