A working solution (it seems):
dtest.zip
cCubeX.zip
- Code: Select all
function TXMLPivotCubeExport.Execute(AFileName: string): boolean;
procedure ExpandCell(var AXML : string; ACell : ICell);
var
C : integer;
dname : string; //dimension name
begin
if (ACell.ChildCount > 0) then
begin
dname := ACell.Childs[0].DimensionItem.Dimension.DisplayName;
XMLOpen(AXML, 'dimension', 'name="'+dname+'"');
for C := 0 to (ACell.ChildCount - 1) do begin
if (not ACell.Empty) then
begin
XMLAppend(AXML, 'node', ACell.Childs[C].Caption);
XMLAppend(AXML, 'value', floattostr(FPivotMap.RowTotal[ACell.Childs[C].Position, 0, mvtValue]));
ExpandCell(AXML, ACell.Childs[C]);
end;
end;
XMLClose(AXML, 'dimension');
end;
end;
var
C, R, Ri, M : integer;
xn_cube, xn_nodes : string;
xml : TNativeXML;
value : double;
rcell, ccell : ICell;
rname, cname : string;
begin
//row "row style" exports
ExpandCell(xn_nodes, FPivotMap.TopRows);
XMLAppend(xn_cube, 'parts', xn_nodes);
XMLWrap(xn_cube, 'cube');
try
{validate xml and save}
xml := TNativeXML.Create;
xml.ReadFromString(xn_cube);
xml.SaveToFile(AFileName);
finally
xml.free;
end;
end;
Please check if this is acceptable/correct/functional/sane.
Issues:
1. The XML structure is not finalized so the result looks odd but is correct and gets the RowTotal values (will be doing full columns dims and rows dims + columnstotals if this works)
2. Some Childs are still added which should not
- in the the XML file in the attached sample - see the nodes at lines 47, 51 etc or see the cube and view files and compare to XML
Thanks in advance