Break line automatically on export to Excel by Delphi

Asked

Viewed 628 times

0

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

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 holds a multi-line concatenation.

1 answer

1


You can use the function Wraptext, setting the maximum number of characters per line you want and it will return the string with the required line breaks.

Uses
  System.SysUtils;

...    
CaracteresPorLinha := 40;
Sheet.Range['M' + IntToStr(iLin)] := WrapText(sTexto, CaracteresPorLinha);
...
  • Thank you very much! It worked out and was excellent!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.