Cell displays text with CRLF as one line

XLSX_Newline1
XLSX_Newline2

Based on the simple example of your documentation I tried to create a file, put a text with a newline in a cell and save it.
When opening that file with Excel (both Excel2010 and Excel2019) there is a strange behaviour.
That cell displays the text without newline in the cell itself and as two lines in the editfield.
When I click in the editfield once the text in the cell changes to a two line display too, as it is intended.
Do you have an idea how to display a two line cell immediately after opeing ?

Here is the sourcecode :slight_smile:
procedure TExcelData.CreateExcelFile;
var
h, w: integer;
xls: TXlsFile;
begin
// Create a new empty Excel file, with default formatting as if it was created by Excel 2019.
xls := TXlsFile.Create(1, TExcelFileFormat.v2019, true);
try
// Caution, #10#13 writes double CRLF, use #13#10
h := xls.GetRowHeight(3);
w := xls.GetColWidth(1);
xls.SetRowHeight(3, h * 3);
xls.SetColWidth(1, w * 3);
xls.SetCellValue(3, 1, 'Company Name : '+ #13#10 + 'Cranelock');
xls.Save(TPath.Combine(QsStatPath, 'test.xlsx'));
finally
xls.Free;
end;
end;

Hi,
You need to set the cell format to "wrap text" or Excel will show it in a single line even if it has carriage returns. When you press F2->Enter Excel silently changes the cell format without telling you, but that's something we don't do.

Look at Entering multiple lines of text inside a cell | FlexCel Studio for VCL and FireMonkey documentation

Just set the text you want in Excel, save the file, open the file with APIMate (search for apimate in the start menu), and it will tell you the command to set the cell format and the cell value (you are already setting the cell value, so it is just the cell format that you are missing)