Copy link to clipboard
Copied
Saw note to use getColumn width from a static function but don't know how to call it within coldfusion.
static int getWidth(Sheet sheet, int col) { int width = sheet.getColumnWidth(col); if (width == sheet.getDefaultColumnWidth()) { width = (int) (width * 256); } return width;}
Robert,
It is relatively easy to use the underlying POI library once you get a hook into it with CF.
<!--- create the spreadsheet with ColdFusion --->
<cfset sObj = SpreadsheetNew("mySpreadsheet") />
<!--- fill your spreadsheet with your data / query however --->
<!--- get a handle on the ColdFusion underlying POI object --->
<cfset objWorkbook = sObj.getWorkbook() />
<!--- get a handle on the workbook's sheet --->
<cfset objSheet = objWorkbook.getSheetAt(objWorkbook.getActiveSheetIndex()) />
<!--- the
...Some additional suggestions to @Kevin D. Wright 's code:
<cfparam name="variables.columnIndex" default="0">
This is related to the next bullet-point.
See for example https://poi.apache.org/apidocs/dev/org/apache/poi/ss/usermodel/Sheet.html#getColumnWidth-int-
...Copy link to clipboard
Copied
Robert,
It is relatively easy to use the underlying POI library once you get a hook into it with CF.
<!--- create the spreadsheet with ColdFusion --->
<cfset sObj = SpreadsheetNew("mySpreadsheet") />
<!--- fill your spreadsheet with your data / query however --->
<!--- get a handle on the ColdFusion underlying POI object --->
<cfset objWorkbook = sObj.getWorkbook() />
<!--- get a handle on the workbook's sheet --->
<cfset objSheet = objWorkbook.getSheetAt(objWorkbook.getActiveSheetIndex()) />
<!--- then you can reference the columns within the sheet and get it's width --->
<cfset myColWidth = objSheet.getColumnWidth(columnIndex) />
Copy link to clipboard
Copied
Some additional suggestions to @Kevin D. Wright 's code:
<cfparam name="variables.columnIndex" default="0">
This is related to the next bullet-point.
See for example https://poi.apache.org/apidocs/dev/org/apache/poi/ss/usermodel/Sheet.html#getColumnWidth-int-
Copy link to clipboard
Copied
Thanks