View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Displaying multiline Text into Excel Cell through Interop


A quick test shows SQL returning a CrLf
chr$(13)&chr$(10)

Excel wrapped cells use just an LF chr(10).

You could do THIS after you've inserted the query...

Cells.Replace What:="" & Chr(10) & "", Replacement:="", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False




alternatively you could use Replace function in your query:

SELECT Replace([Table1]![textwrapped],Chr(10),"") AS ExcelWrapped
FROM Table1;





keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Karthikeyan" wrote:

Hi,
The scenario is, I have data in SQL server, which needs
to be populated in Excel Sheet through interop. The data
in SQL Server contains new line characters also. I need
to display the text as multiline text into the Excel
Cell. When we just assign the text, the excel engine
renders the new line characters as special characters
(weired character like a square box). Any Solutions..

Thanks in Advance
Karthik