Hi René,
I changed the example in in the help file, which you can refer to:
void Datasheet_SetReportTree_Ex1_new(bool bTransposeTable = false)
{
int nID = 1000;
int nTableFormat = GETNBRANCH_OPEN | GETNBRANCH_HIDE_COL_HEADINGS| GETNBRANCH_HIDE_ROW_HEADINGS | GETNBRANCH_FIT_COL_WIDTH | GETNBRANCH_FIT_ROW_HEIGHT;
// 1. Create report tree
Tree tr;
tr.Report.ID = nID++;
tr.Report.SetAttribute(STR_LABEL_ATTRIB, "Sample Report Tree"); //Table title
// TREE_Table attribute is critical in getting the report to work so must be present in every table level.
// Can set this attribute as 0 without any format, but many bits GETNBRANCH_* defined in oc_const.h to set table display format.
tr.Report.SetAttribute(TREE_Table, nTableFormat);
// 2. Create report table
tr.Report.Table.ID = nID++;
tr.Report.Table.SetAttribute(STR_LABEL_ATTRIB, "This is a simple table"); // Table title. If not set this, will show as empty here
int nSubTableFormat = nTableFormat;
if(bTransposeTable)
nSubTableFormat |= GETNBRANCH_TRANSPOSE; // transpose this table
tr.Report.Table.SetAttribute(TREE_Table, nSubTableFormat);
//3. add rows and columns to this table
int nRows = 8;
int iRow = 0;
while(iRow++ < nRows)
{
string strRx = "Row" + iRow;
string strLabel = "Row " + iRow;
TreeNode trRx = tr.Report.Table.AddNode(strRx);
trRx.ID = nID++;
trRx.SetAttribute(STR_LABEL_ATTRIB, strLabel);
//col
int nCols = 2;
int iCol = 0;
int nColID = 3210;
while(iCol++ < nCols)
{
string strCx = "Col" + iCol;
TreeNode trCx = trRx.AddNode(strCx);
trCx.ID= nColID++;
trCx.dVal = 15;
}
}
//7. Prepare worksheet window to report
WorksheetPage wksPage;
wksPage.Create();
DWORD dwOptions = WP_SHEET_HIERARCHY | CREATE_NO_DEFAULT_TEMPLATE;
string strSheetName = "Report Sheet";
int nn = wksPage.AddLayer(strSheetName, dwOptions);
if( nn < 0 )
return;
Worksheet wksOut = wksPage.Layers(nn);
wksPage.Layers(0).Delete(); //delete the first default layer
// 8. Do report
if( wksOut.SetReportTree(tr.Report) < 0 ) // Returns last row number on successful exit and -1 on failure.
{
printf("Fail to set report tree.\n");
return;
}
wksOut.AutoSize();
//out_tree(tr);
}
Hope it helps!
Yuki
OriginLab