Line Breaks in cells

Questions and answers on how to use XLSReadWriteII 3/4/5.
Post Reply
Schmulm
Posts: 2
Joined: Sun Jul 19, 2020 10:11 am

Line Breaks in cells

Post by Schmulm »

Hi,
How can I insert a line break in a cell in a way that it is displayed correctly?
I tried: AsString[0,0] := 'line1' + sLinebreak + 'line2';
When I open the excel file, the content of the first cell is "line1line2".
But when I simply click into the cell and press F2 and Enter, then the text is displayed correctly with the line break.
So, it somehow works to a certain extent.
I want Excel to show the line break right after opening the file without any unnecessary clicking.
How can this be done?

Thanks
Schmulm
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Line Breaks in cells

Post by larsa »

Hello

You must set WrapText := True

Example:

Code: Select all

XLS[0].AsString[1,1] := 'One' + #10 + 'Two';
XLS[0].Cell[1,1].WrapText := True;
Lars Arvidsson, Axolot Data
Schmulm
Posts: 2
Joined: Sun Jul 19, 2020 10:11 am

Re: Line Breaks in cells

Post by Schmulm »

Thanks
Post Reply