How to make merged cells? lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- alexs75 · 2014-09-01 17:32 How to make merged cells? ---------------------------------------------------------------------- Never · 2014-09-01 19:22 be more specific alexs75 ---------------------------------------------------------------------- wp · 2014-09-01 21:08 Currently merging of cells is not working with TStringGrid. I once tried to implement that feature in descendant (TChartGrid which you may find somewhere in this forum) but never finished it. It requires overriding of some of the basic painting methods. ---------------------------------------------------------------------- alexs75 · 2014-09-02 03:03 I'm write spreadsheet. It's for export data from RxDbGrid and from LazReport. After export this file opened in LibreOffice. And for best view I'm need make merged cell. ---------------------------------------------------------------------- wp · 2014-09-02 07:04 The same with fpspreadsheet. Merging is on my list, but I want to finish other topics first. ---------------------------------------------------------------------- alexs75 · 2014-09-11 19:54 If the table several groups merged cells, then stored only the last group. ---------------------------------------------------------------------- wp · 2014-09-11 20:32 The initial version of merged cells is now in fpspreadsheet. Just call TsWorksheet.Mergecells() and pass the cell block to be merged either as an Excel cell range string, or by column and row indexes: Code: [Select]  MyWorksheet.MergeCells('A1:D5'); //or   MyWorksheet.MergeCells(0, 0, 4, 3);  // first row, first column, last row, lst column The contents of the merged block is defined by the upper left cell, in this example A1. The other cells are ignored (or will even be deleted, I am not quite sure yet). Merged cells can be written to and read from xls, xlsx and ods files (xls only as sfExcel8, because the other variants do not support merging internally). Note, however, that the xls writer produces a defective file, a bug which I could not identify so far. The worksheet grid displays merged cells in the usual way; this is very new and not fully complete. You have to use the trunk version to get this feature. But since everything is very fresh be prepared of some incompatible changes here and there. ---------------------------------------------------------------------- alexs75 · 2014-09-11 20:54 I'm merge 2 range:  MyWorksheet.MergeCells(0, 0, 2, 2);  MyWorksheet.MergeCells(4, 4, 6, 6); Save this worksheet to XLS file. After i'm open i'ts on LibreOffise  merged only 4, 4, 6, 6 1-th range not saved. ---------------------------------------------------------------------- wp · 2014-09-11 21:22 As I wrote, xls files with merged cells are not written correctly at the moment. I tested writing to ods, and the two blocks do arrive there. ---------------------------------------------------------------------- wp · 2014-09-12 18:29 Stupid error... The bug in the biff8 writer producing faulty xls files for merged cells is now fixed.