[SOLVED] FPSpreadSheet - Newline in WriteText lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- JD · 2017-04-17 13:52 Hi there everyone, I create Excel worksheets using FPSpreadSheet and most of the cells are of the format below 11:30 - 13:30: Travail divers; 15:00 - 18:00: Linguistique; The semi-colon ';' is used as a delimiter in this context. Is there any way to write the text into the cells in such a way that when the semi-colon (or any chosen delimiter e.g '|') is encountered, a new line is created and the end result as shown below is what will be written to the cells: 11:30 - 13:30: Travail divers 15:00 - 18:00: Linguistique I'm thinking of something like a new WriteCell method or a WriteChar method. Thanks, JD ---------------------------------------------------------------------- wp · 2017-04-17 17:19 I won't add another WriteXXX method for this simple use case - there are already too many overloaded methods... Why don't you split the string yourself at the semicolon and add the parts individually? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program project1; {$mode objfpc}{$H+} uses  Classes, SysUtils, fpspreadsheet, fpstypes, xlsxooxml; var  book: TsWorkbook;  sheet: TsWorksheet;   procedure AddMultiCell(ARow, ACol: Integer; AText: String);  var    strArray: TStringArray;    i: Integer;  begin    strArray := AText.Split(';');    for i := 0 to High(strArray) do      if strArray[i] <> '' then        sheet.WriteText(ARow + i, ACol, Trim(strArray[i]));  end; begin  book := TsWorkbook.Create;  try    sheet := book.AddWorksheet('Sheet 1');    AddMultiCell(0, 0, '11:30 - 13:30: Travail divers; 15:00 - 18:00: Linguistique;');    book.WriteToFile('test.xlsx', sfOOXML, true);  finally    book.Free;  end; end. ---------------------------------------------------------------------- JD · 2017-04-18 09:20 Hi there wp, Thanks for your reply. I understand your reluctance to add more overloaded methods.  I forgot to add that it should be in the same cell on the same row. In LibreOffice/OpenOffice, I had to type CTRL+ENTER in the position after the delimiter ';'. In Excel, it is ALT+ENTER. Thanks, JD ---------------------------------------------------------------------- wp · 2017-04-18 10:21 Then replace the semicolon by FPS_LINE_ENDING (which is #10) defined in fpstypes (the following code also removes the space after the semicolon), activate word-wrap, and set column width and row height appropriately. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   procedure AddWrappedCell(ARow, ACol: Integer; AText: String);  var    strArray: TStringArray;    i: Integer;    s: String;  begin    strArray := AText.Split(';');    s := trim(strArray[0]);    for i := 1 to High(strArray) do      if strArray[i] <> '' then        s := s + FPS_LINE_ENDING + trim(strArray[i]);    sheet.WriteText(ARow, ACol, s);    sheet.WriteWordwrap(ARow, ACol, true);  end;  begin  book := TsWorkbook.Create;  try    sheet := book.AddWorksheet('Sheet 1');    AddWrappedCell(3, 0, '11:30 - 13:30: Travail divers; 15:00 - 18:00: Linguistique;');    sheet.WriteColWidth(0, 50, suMillimeters);    // column width: 50 mm    sheet.WriteRowHeight(3, 2.5, suLines);        // row height: 2 lines plus some margin    book.WriteToFile('test.xlsx', sfOOXML, true);   finally    book.Free;  end;end. ---------------------------------------------------------------------- JD · 2017-04-18 10:27 Wonderful. Works perfectly. Thanks a lot!