Cells range borders lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- jcmontherock · 2018-03-08 14:53 I am starting to play with the sample «demo_virtualmode_write». I'm able to define a cells range, but I can't find how to draw a border around the range (sheet for example). How to do that ? ---------------------------------------------------------------------- wp · 2018-03-10 09:24 Since there is no Range variant of the WriteBorder methods you must iterate through the cells at the border of the range and set the borders accordingly (Worksheet.WriteBorders, .WriteBorderStyle -- see http://wiki.lazarus.freepascal.org/FPSpreadsheet#Cell_borders). It's a bit lengthy, though... ---------------------------------------------------------------------- jcmontherock · 2018-03-13 17:32 Thanks for your answer. For a big table lengthy is the word....    ;O) ---------------------------------------------------------------------- wp · 2018-03-13 18:03 No, using loops it is no difference whether you deal  with a 2x2 or a 100x100 range. The problem is the in the many cases. Here is a simple demo with an outer border only: 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  SysUtils,  fpstypes, fpspreadsheet, fpsallformats;   procedure WriteBorder(ASheet: TsWorksheet; ALeft,ATop,ARight,ABottom: Integer;    ALeftStyle, ATopStyle, ARightStyle, ABottomStyle: TsCellBorderStyle);  var    r, c: Integer;    cell: PCell;  begin    for c := ALeft to ARight do begin      ASheet.WriteBorderStyle(ATop, c, cbNorth, ATopStyle);      ASheet.WriteBorders(ATop, c, [cbNorth]);      ASheet.WriteBorderStyle(ABottom, c, cbSouth, ABottomStyle);      ASheet.WriteBorders(ABottom, c, [cbSouth]);    end;    for r := ATop to ABottom do begin      ASheet.WriteBorderStyle(r, ALeft, cbWest, ALeftStyle);      ASheet.WriteBorders(r, ALeft, [cbWest]);      ASheet.WriteBorderStyle(r, ARight, cbEast, ARightStyle);      ASheet.WriteBorders(r, ARight, [cbEast]);    end;    ASheet.WriteBorders(ATop, ALeft, [cbNorth, cbWest]);    ASheet.WriteBorders(ABottom, ALeft, [cbSouth, cbWest]);    ASheet.WriteBorders(ATop, ARight, [cbNorth, cbEast]);    ASheet.WriteBorders(ABottom, ARight, [cbSouth, cbEast]);  end; var  book: TsWorkbook;  sheet: TsWorksheet;  r, c: Cardinal; const  ThinBorder: TsCellBorderStyle = (Linestyle:lsThin; Color:scBlack);  ThickBorder: TsCellBorderStyle = (LineStyle:lsThick; Color:scBlack); begin  book := TsWorkbook.Create;  try    sheet := book.AddWorksheet('Test');    for r := 0 to 99 do      for c := 0 to 99 do        sheet.WriteText(r, c, Format('R%dC%d', [r,c]));     WriteBorder(sheet, 5, 5, 50, 50, ThickBorder, ThinBorder, ThickBorder, ThinBorder);     book.WriteToFile('test.xlsx', sfOOXML, true);  finally    book.Free;  end; end. ---------------------------------------------------------------------- jcmontherock · 2018-03-21 17:47 Thanks a lot. It's what I was looking for.