Ask Ben: Getting Line Breaks To Work In A ColdFusion And POI Generated Excel Document

<!--- Create a query from scratch for our list of movies. --->
<cfset qMovie = QueryNew(
	"id, name, date_watched, rating, has_fighting, has_boobies",
	"CF_SQL_INTEGER, CF_SQL_VARCHAR, CF_SQL_VARCHAR, CF_SQL_DECIMAL, CF_SQL_INTEGER, CF_SQL_INTEGER"
	) />
 
<!--- Add rows to query. --->
<cfset QueryAddRow( qMovie, 5 ) />
 
<!--- Set row data. --->
<cfset qMovie[ "id" ][ 1 ] = JavaCast( "int", 1 ) />
<cfset qMovie[ "name" ][ 1 ] = JavaCast( "string", "Terminator 2:#Chr( 10 )#Judgment Day" ) />
<cfset qMovie[ "date_watched" ][ 1 ] = JavaCast( "string", "2006/05/25" ) />
<cfset qMovie[ "rating" ][ 1 ] = JavaCast( "float", 10.0 ) />
<cfset qMovie[ "has_fighting" ][ 1 ] = JavaCast( "boolean", true ) />
<cfset qMovie[ "has_boobies" ][ 1 ] = JavaCast( "boolean", false ) />
 
<cfset qMovie[ "id" ][ 2 ] = JavaCast( "int", 2 ) />
<cfset qMovie[ "name" ][ 2 ] = JavaCast( "string", "American Pie" ) />
<cfset qMovie[ "date_watched" ][ 2 ] = JavaCast( "string", "2005/08/02" ) />
<cfset qMovie[ "rating" ][ 2 ] = JavaCast( "float", 9.0 ) />
<cfset qMovie[ "has_fighting" ][ 2 ] = JavaCast( "boolean", false ) />
<cfset qMovie[ "has_boobies" ][ 2 ] = JavaCast( "boolean", true ) />
 
<cfset qMovie[ "id" ][ 3 ] = JavaCast( "int", 3 ) />
<cfset qMovie[ "name" ][ 3 ] = JavaCast( "string", "Friends With Money" ) />
<cfset qMovie[ "date_watched" ][ 3 ] = JavaCast( "string", "2006/06/21" ) />
<cfset qMovie[ "rating" ][ 3 ] = JavaCast( "float", 8.0 ) />
<cfset qMovie[ "has_fighting" ][ 3 ] = JavaCast( "boolean", false ) />
<cfset qMovie[ "has_boobies" ][ 3 ] = JavaCast( "boolean", false ) />
 
<cfset qMovie[ "id" ][ 4 ] = JavaCast( "int", 4 ) />
<cfset qMovie[ "name" ][ 4 ] = JavaCast( "string", "Better Than Chocolate" ) />
<cfset qMovie[ "date_watched" ][ 4 ] = JavaCast( "string", "2006/10/07" ) />
<cfset qMovie[ "rating" ][ 4 ] = JavaCast( "float", 8.5 ) />
<cfset qMovie[ "has_fighting" ][ 4 ] = JavaCast( "boolean", true ) />
<cfset qMovie[ "has_boobies" ][ 4 ] = JavaCast( "boolean", true ) />
 
<cfset qMovie[ "id" ][ 5 ] = JavaCast( "int", 5 ) />
<cfset qMovie[ "name" ][ 5 ] = JavaCast( "string", "Real Genius" ) />
<cfset qMovie[ "date_watched" ][ 5 ] = JavaCast( "string", "2006/12/12" ) />
<cfset qMovie[ "rating" ][ 5 ] = JavaCast( "float", 9.0 ) />
<cfset qMovie[ "has_fighting" ][ 5 ] = JavaCast( "boolean", false ) />
<cfset qMovie[ "has_boobies" ][ 5 ] = JavaCast( "boolean", false ) />
 
 
<!--- Create a new instance of the POI utility. --->
<cfset objPOIUtility = CreateObject(
	"component",
	"POIUtility"
	).Init()
	/>
 
<!--- Get the path to our Excel document. --->
<cfset strFilePath = ExpandPath( "./multi_line.xls" ) />
 
 
<!--- Create default sheet object. --->
<cfset objSheet = objPOIUtility.GetNewSheetStruct() />
 
<!--- Set sheet query data. --->
<cfset objSheet.Query = qMovie />
 
<!---
	This is the name that will show up in the first
	Excel sheet tab.
--->
<cfset objSheet.SheetName = "Movies" />
 
<!---
	This is the list of columns that we want to use. This
	specifies the columns AND the order in which they
	should appear.
--->
<cfset objSheet.ColumnList = "id,name,rating,date_watched,rating,has_fighting,has_boobies" />
 
<!--- This defines the header row values. --->
<cfset objSheet.ColumnNames = "ID,Name,Rating,Date Watched,Rating,Has Fighting,Has Boobies" />
 
 
<!---
	Write the excel from the query. We are passing in the
	CSS values for the header, row, and altrow.
--->
<cfset objSheet = objPOIUtility.WriteExcel(
	FilePath = strFilePath,
	Sheets = objSheet,
	HeaderCSS = "font: italic 16pt verdana ; background: lime ; color: white ; border-bottom: 3px solid green ;",
	RowCSS = "border-bottom: 1px solid gold ; font-size: 12pt ;",
	AltRowCSS = "background-color: lemon_chiffon ;"
	) />

For Cut-and-Paste