Break line automatically in export to Excel by Delphi

0

I'm doing an export to Excel using Delphi. At some point, a text ends up being larger than the size of the cell, "popping" its contents out of the cell when opening the generated .XLSX file.

I would like to know the command used to apply the effect of the button "Break Text Automatically" by Delphi.

Follow the command to generate the text in the cell:

Sheet.Range['M' + IntToStr(iLin)] := sTexto;

This variable sTexto saves a multi-line concatenation.

    
asked by anonymous 17.09.2018 / 19:21

1 answer

1

You can use the WrapText function by setting the maximum number of characters per line that you want and it returns the string with the required line breaks.

Uses
  System.SysUtils;

...    
CaracteresPorLinha := 40;
Sheet.Range['M' + IntToStr(iLin)] := WrapText(sTexto, CaracteresPorLinha);
...
    
17.09.2018 / 19:59