Recent

Author Topic: How to make merged cells?  (Read 8718 times)

alexs75

  • Full Member
  • ***
  • Posts: 112
How to make merged cells?
« on: September 01, 2014, 07:32:59 pm »
How to make merged cells?

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: How to make merged cells?
« Reply #1 on: September 01, 2014, 09:22:33 pm »
be more specific alexs75
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

wp

  • Hero Member
  • *****
  • Posts: 11906
Re: How to make merged cells?
« Reply #2 on: September 01, 2014, 11:08:39 pm »
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

  • Full Member
  • ***
  • Posts: 112
Re: How to make merged cells?
« Reply #3 on: September 02, 2014, 05:03:06 am »
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

  • Hero Member
  • *****
  • Posts: 11906
Re: How to make merged cells?
« Reply #4 on: September 02, 2014, 09:04:37 am »
The same with fpspreadsheet. Merging is on my list, but I want to finish other topics first.

alexs75

  • Full Member
  • ***
  • Posts: 112
Re: How to make merged cells?
« Reply #5 on: September 11, 2014, 09:54:43 pm »
If the table several groups merged cells, then stored only the last group.

wp

  • Hero Member
  • *****
  • Posts: 11906
Re: How to make merged cells?
« Reply #6 on: September 11, 2014, 10:32:21 pm »
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

  • Full Member
  • ***
  • Posts: 112
Re: How to make merged cells?
« Reply #7 on: September 11, 2014, 10:54:18 pm »
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

  • Hero Member
  • *****
  • Posts: 11906
Re: How to make merged cells?
« Reply #8 on: September 11, 2014, 11:22:52 pm »
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

  • Hero Member
  • *****
  • Posts: 11906
Re: How to make merged cells?
« Reply #9 on: September 12, 2014, 08:29:00 pm »
Stupid error... The bug in the biff8 writer producing faulty xls files for merged cells is now fixed.

 

TinyPortal © 2005-2018