Forum > FPSpreadsheet

Can we create pivotable

(1/2) > >>

Packs:
Can we create pivotable

Thaddy:
Yes. Why not?
Simple example:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program PivotTable;{$mode objfpc}type  TData = record    Category: string;    Value: Integer;  end; var  Data: array[1..5] of TData;  Summary: array[1..2] of record    Category: string;    Total: Integer;  end;  i, j: Integer; begin  // Sample data  Data[1].Category := 'A'; Data[1].Value := 10;  Data[2].Category := 'B'; Data[2].Value := 20;  Data[3].Category := 'A'; Data[3].Value := 30;  Data[4].Category := 'B'; Data[4].Value := 40;  Data[5].Category := 'A'; Data[5].Value := 50;   // Initialize summary  Summary[1].Category := 'A'; Summary[1].Total := 0;  Summary[2].Category := 'B'; Summary[2].Total := 0;   // Process data  for i := 1 to Length(Data) do  begin    for j := 1 to Length(Summary) do    begin      if Data[i].Category = Summary[j].Category then      begin        Summary[j].Total := Summary[j].Total + Data[i].Value;        Break;      end;    end;  end;   // Output results  writeln('Category', #9, 'Total');  for i := 1 to Length(Summary) do  begin    writeln(Summary[i].Category, #9, Summary[i].Total);  end;end.You probably want something more advanced, which can be done with rtti and generics or sql query.
Principle is the same, though: summarize arbitrary tabular data based on arbitrary fields in a structure.

Packs:
Thanks sir.

how to do it in fpspreadsheet .

Thaddy:
Ask wp, but I guess there is something.

wp:
There are no plans to add this feature to fpspreadsheet.

Navigation

[0] Message Index

[#] Next page

Go to full version