Skip to main content
Participating Frequently
August 21, 2008
Question

Cffile - Blank lines in Excel

  • August 21, 2008
  • 3 replies
  • 673 views
I am writing records into excel file using CFFILE. The charset is UTF16 as I need to insert Korean characters.

But I realised blank line is inserted to every record.
Can someone advise how can I remove the blank line.
This topic has been closed for replies.

3 replies

munmun77Author
Participating Frequently
August 22, 2008
Thank you all for the advise.
Inspiring
August 21, 2008
You were appending a second table to the first.
Solution: Use <cfsavecontent> and write your content into the Excel file.

<cfprocessingDirective pageencoding="utf-8">
<cfset setEncoding("form","utf-8")>
<cfquery name="GetScreen_Login" dataSource="VOCTEST">
select STR_EN, STR_FXK FROM VC_SCREEN_STR where STR_SECTION = 'LOGIN'
</cfquery>

<!--- Create table --->
<cfsavecontent variable="myExcelTable">
<table border="1" cellpadding="0" cellspacing="0">
<tr valign="top">
<td><b>Eng</b></td>
<td><b>Kor</b></td>
</tr>
<cfoutput query="GetScreen_Login">
<tr valign="top">
<td>#STR_EN#</td>
<td>#STR_FXK#</td>
</tr>
</cfoutput>
</table>
</cfsavecontent>

<!--- Write table to Excel File --->
<cffile action="write" file="D:\CustomerVoice\Test_Excel.xls" addnewline="no" charset = "utf-16" output="#myExcelTable#" />
Inspiring
August 21, 2008
You probably have too many table tags. For the entire file, you only need one at the start and one at the end.

Try using cfsavecontent to create your entire table and then output the resulting variable into your file.