1

How to insert line breaks when writing macros in libreoffice calc?

e.g:

oCell.SetString("hello /? world!")

Out:

hello
world!
Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
kendallbp
  • 61
  • 5
  • `oCell.setString("Hello" & `[**Chr**](https://help.libreoffice.org/7.3/en-US/text/sbasic/shared/03120102.html)`(10) & "world!")` – JohnSUN Mar 15 '22 at 05:18
  • @JohnSUN If this is a working solution, please write an answer. Comments are not for answers. – the busybee Mar 15 '22 at 07:40
  • @thebusybee Yes, I know what the answer should be - tell in detail about the CR and LF, about the CHR() function, about the features of text breaks in spreadsheet cells. If all this is described, it will be a useful answer. I'm sorry, I don't have time for that right now, an air raid alert has been announced again, Kyiv is being shelled again. If someone can write the correct answer, then I will be very happy. – JohnSUN Mar 15 '22 at 07:47
  • @JohnSUN If you're located in Ukraine, our thoughts are with you. We have just received refugees in our home, it's one thing we can do right now. All the best! – the busybee Mar 15 '22 at 09:29

1 Answers1

3

As explained in the help docs at Inserting Line Breaks in Cells, a line break in Calc is ASCII 10. So use the Chr function.

oCell.setString("Hello" & Chr(10) & "world!")

P.S. to JohnSUN, who wrote this example: We are praying for you and those close to you during this difficult time.

Jim K
  • 12,824
  • 2
  • 22
  • 51