views:

502

answers:

1

Hi,

Can I get merged cells in some rows while other rows cells remain not merged? Like this way:

| group row 1                              |
| cell1 | cell3 | cell4 | cell5 | cell6 |
| cell1 | cell3 | cell4 | cell5 | cell6 |
...
| group row 2                              |
...
I have to export to Excel content of datagridview with group rows and it would be nice to get something like that. I've tried to use ColSpan element in TableCell but it affects all rows.

Thanks for help

A: 

I've found solution. TableCell element can contain ColSpan element in which one can point amount of cells have to merged to this cell. Other interesting question is: how to use this in the best way? My current approach is following.
1. Detect all kinds of rows in grid regarding to merging cells in them (in my example there're 2 kinds - simple row without merging and "group" row with one cell that merges all cells).
2. Define TableRow element for each kind of row using ColSpan element in order to merge cells. When using TextBox element in cells don't forget to set unique names for all TextBox elements in report.
3. Set visibility for each type of row. I can't yet find better way than simple enumerating row indexes just like this:

<Visibility>
 <Hidden>=iif(RowNumber(Nothing) = 1 or RowNumber(Nothing) = 5 or RowNumber(Nothing) = 8, true, false)</Hidden>
</Visibility>

Make sure that each row in grid matches "Hidden=false"condition from no more than one TableRow element.

Remarks and suggestions are welcome.

dostoyevsky