Hello Avnish,
Thank you very much for your efforts. I did not immediately understand the use of the formulas and through trial and error came up with a simple working solution. Suppose there is a table with 30 rows:
| ColumnType: Number | ColumnType: String | ColumnType: Date | ColumnType: String | ColumnType: String | ColumnType: Number |
| ID | EDITTYPE | EDITA | EDITBY | EDITLOCATION | ColumnA |
|----------------------|----------------------|----------------------|----------------------|----------------------|----------------------|
| 1 | 0 | 15.05.2022 | S.Sample man | MADS | 1 |
| 2 | 0 | 14.05.2022 | A.Sample man | MADS | 8 |
| 3 | 0 | 13.05.2022 | M.Sample man | MADS | 27 |
| ... | ... | ... | ... | ... | ... |
The content of the File Form1.vb:
Public Class Form1
Private m_Table As New DataTable()
Sub CreateColumns(ByVal editable As Boolean)
Me.m_Table.Columns.Add(New DataColumn() With {.ColumnName = "ID", .DataType = GetType(Long), .AutoIncrement = True, .AutoIncrementSeed = 1})
Me.m_Table.Columns.Add(New DataColumn() With {.ColumnName = "EDITTYPE", .DataType = GetType(Char), .ReadOnly = Not editable})
Me.m_Table.Columns.Add(New DataColumn() With {.ColumnName = "EDITA", .DataType = GetType(Date), .ReadOnly = Not editable})
Me.m_Table.Columns.Add(New DataColumn() With {.ColumnName = "EDITBY", .DataType = GetType(String), .ReadOnly = Not editable})
Me.m_Table.Columns.Add(New DataColumn() With {.ColumnName = "EDITLOCATION", .DataType = GetType(String), .ReadOnly = Not editable})
Me.m_Table.Columns.Add(New DataColumn() With {.ColumnName = "ColumnA", .DataType = GetType(Decimal), .ReadOnly = Not editable})
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.CreateColumns(editable:=False)
Me.spr_Main_Sheet1.DataSource = (New Testdata(Me.m_Table, rowCount:=30).Table)
Dim gdm As New GroupDataModel(Me.spr_Main_Sheet1.Models.Data)
Dim sortInfos As New List(Of SortInfo)()
sortInfos.Add(New SortInfo(3, ascending:=True)) ' Sorted by column EDITBY
gdm.Group(sortInfos.ToArray())
gdm.GroupFooterVisible = True
Me.spr_Main_Sheet1.Models.Data = gdm
End Sub
Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles Me.Shown
Dim gdm = DirectCast(Me.spr_Main_Sheet1.Models.Data, GroupDataModel)
' The format dd.mm.yyyy using dots (which denote ordinal numbering) is the traditional German date format, see here https://en.wikipedia.org/wiki/Date_format_by_country
Dim dateFormat = "dd.MM.yyyy"
Me.spr_Main_Sheet1.Columns(2).CellType = New CellType.DateTimeCellType() With {.DateTimeFormat = CellType.DateTimeFormat.UserDefined, .UserDefinedFormat = dateFormat}
For i = 0 To gdm.Groups.Count - 1
Dim group = DirectCast(gdm.Groups(i), Group)
DirectCast(group.GroupFooter.DataModel, IAggregationSupport).SetCellAggregationType(row:=0, col:=2, type:=AggregationType.Max) ' column EDITA
DirectCast(group.GroupFooter.DataModel, IAggregationSupport).SetCellAggregationType(row:=0, col:=5, type:=AggregationType.Max) ' column ColumnA
' in German region is a decimal separator a , see here https://en.wikipedia.org/wiki/Decimal_separator and the , is also displayed. Example: "24389,00" This is ok.
DirectCast(group.GroupFooter.DataModel, IAggregationSupport).SetCellAggregationFormat(row:=0, col:=5, format:="{0:0.00}")
For primaryRowIndex = 0 To group.Rows.Count - 1
If TypeOf group.Rows(primaryRowIndex) Is Integer Then
Dim dm = DirectCast(group.GroupFooter.DataModel, AggregationDataModel)
Dim value = dm.GetValue(row:=0, col:=2) ' column EDITA
If TypeOf value Is Double Then
dm.SetValue(row:=0, col:=2, Date.FromOADate(Convert.ToDouble(value)).ToString(dateFormat))
End If
End If
Next
Next
End Sub
End Class
Grouping is done by the EDITBY column and the EDITA and ColumnA columns have group feet. These group footers are now perfectly formatted by my solution above.
| ID | EDITTYPE | EDITA | EDITBY | EDITLOCATION | ColumnA |
|----------------------|----------------------|----------------------|----------------------|----------------------|----------------------|
| 2 | 0 | 14.05.2022 | A.Sample man | MADS | 8 |
| 27 | 0 | 19.04.2022 | A.Sample man | MADS | 19683 |
| 9 | 0 | 07.05.2022 | A.Sample man | MADS | 729 |
| 11 | 0 | 05.05.2022 | A.Sample man | MADS | 1331 |
| 20 | 0 | 26.04.2022 | A.Sample man | MADS | 8000 |
| 18 | 0 | 28.04.2022 | A.Sample man | MADS | 5832 |
| 29 | 0 | 17.04.2022 | A.Sample man | MADS | 24389 |
| | | 14.05.2022 | | | 24389 |
| EDITBY: E.Sample man | EDITBY: E.Sample man | EDITBY: E.Sample man | EDITBY: E.Sample man | EDITBY: E.Sample man | EDITBY: E.Sample man |
| 15 | 0 | 01.05.2022 | E.Sample man | MADS | 3375 |
| 6 | 0 | 10.05.2022 | E.Sample man | MADS | 216 |
| 24 | 0 | 22.04.2022 | E.Sample man | MADS | 13824 |
| | | 10.05.2022 | | | 13824 |
| EDITBY: L.Sample man | EDITBY: L.Sample man | EDITBY: L.Sample man | EDITBY: L.Sample man | EDITBY: L.Sample man | EDITBY: L.Sample man |
| 5 | 0 | 11.05.2022 | L.Sample man | MADS | 125 |
| 23 | 0 | 23.04.2022 | L.Sample man | MADS | 12167 |
| 14 | 0 | 02.05.2022 | L.Sample man | MADS | 2744 |
| | | 11.05.2022 | | | 12167 |
| EDITBY: M.Sample man | EDITBY: M.Sample man | EDITBY: M.Sample man | EDITBY: M.Sample man | EDITBY: M.Sample man | EDITBY: M.Sample man |
| 26 | 0 | 20.04.2022 | M.Sample man | MADS | 17576 |
| 21 | 0 | 25.04.2022 | M.Sample man | MADS | 9261 |
| 17 | 0 | 29.04.2022 | M.Sample man | MADS | 4913 |
| 30 | 0 | 16.04.2022 | M.Sample man | MADS | 27000 |
| 12 | 0 | 04.05.2022 | M.Sample man | MADS | 1728 |
| 8 | 0 | 08.05.2022 | M.Sample man | MADS | 512 |
| 3 | 0 | 13.05.2022 | M.Sample man | MADS | 27 |
| | | 13.05.2022 | | | 27000 |
| EDITBY: P.Sample man | EDITBY: P.Sample man | EDITBY: P.Sample man | EDITBY: P.Sample man | EDITBY: P.Sample man | EDITBY: P.Sample man |
| 13 | 0 | 03.05.2022 | P.Sample man | MADS | 2197 |
| 22 | 0 | 24.04.2022 | P.Sample man | MADS | 10648 |
| 4 | 0 | 12.05.2022 | P.Sample man | MADS | 64 |
| | | 12.05.2022 | | | 10648 |
| EDITBY: S.Sample man | EDITBY: S.Sample man | EDITBY: S.Sample man | EDITBY: S.Sample man | EDITBY: S.Sample man | EDITBY: S.Sample man |
| 19 | 0 | 27.04.2022 | S.Sample man | MADS | 6859 |
| 10 | 0 | 06.05.2022 | S.Sample man | MADS | 1000 |
| 28 | 0 | 18.04.2022 | S.Sample man | MADS | 21952 |
| 1 | 0 | 15.05.2022 | S.Sample man | MADS | 1 |
| | | 15.05.2022 | | | 21952 |
| EDITBY: X.Sample man | EDITBY: X.Sample man | EDITBY: X.Sample man | EDITBY: X.Sample man | EDITBY: X.Sample man | EDITBY: X.Sample man |
| 7 | 0 | 09.05.2022 | X.Sample man | MADS | 343 |
| 25 | 0 | 21.04.2022 | X.Sample man | MADS | 15625 |
| 16 | 0 | 30.04.2022 | X.Sample man | MADS | 4096 |
| | | 09.05.2022 | | | 15625 |
My problem is therefore considered solved.
With kind regards
ISD-Internet Dresden, Saxony