Insert line break in Excel cell with Coldfusion 9

I am using Coldfusion 9 to create an Excel spreadsheet. I am using new features like SpreadsheetNew (), SpreadsheetAddRow () and SpreadsheetSetCellValue (). I would like to have data in some cells, including line breaks inside the cell. I tried this with no luck:

<cfset my_spreadsheet = SpreadsheetNew("My Spreadsheet","false")> <cfset cell_value = "First Line"> <cfset carr = chr(13) & chr(10)> <cfset cell_value = cell_value & carr & "Second Line"> <cfset SpreadsheetSetCellValue(my_spreadsheet, cell_value, 1, 1)> 

In Excel output, column 1 of row 1 shows this:

First line Line Line Line

But I want him to show:

First line
Second line

Any thoughts? Thanks!!

+4
source share
1 answer

You need to customize the cell format to enable row wrapping

 <cfset sheet = SpreadsheetNew("My Spreadsheet")> <cfset SpreadsheetSetCellValue(sheet, "foo"& chr(10) &"bar", 1, 1)> <cfset SpreadsheetFormatCell(sheet, {textwrap=true}, 1, 1)> 
+6
source

Source: https://habr.com/ru/post/1390277/


All Articles