Below is the example of using the OpenWbk operation to open a workbook for read. The request contains a workbook instance and data getting pattern. The response contains requested data.
{
"OpenWbk" :
{
"tOb" :
{
"id" : "S1!M!5505"
},
"tArg" :
{
"args" :
{
"openForEdit" : "false"
},
"metaGet" :
{
"obInst" : "true",
"useGridAutoAdjust" : "true",
"series" : "Get",
"seriesFilter" :
{
"includeCollapsed" : "true"
},
"period" : "true",
"rubrs" : "true",
"rubrArg" :
{
"obInst" : "true",
"period" : "true"
}
}
}
}
}
{
"OpenWbkResult" :
{
"id" :
{
"id" : "S1!M!S!W4"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "1",
"@hf" : "0",
"i" : "WBK_AD",
"n" : "Annual data",
"k" : "5505",
"c" : "2827",
"p" : "5471",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"trackElementDependents" : "0",
"isPermanent" : "1",
"isTemp" : "0"
},
"openArgs" : ""
},
"windowsPosition" : "Vertical",
"hasPivot" : "0",
"hasLaner" : "1",
"series" :
{
"@count" : "3",
"its" :
{
"it" :
[
{
"k" : "2",
"id" : "OBJ2",
"n" : "USA|A",
"vis" : "1",
"kind" : "Calculate",
"selectedUnit" : "",
"tag" : "",
"hasChildren" : "0",
"index" : "0",
"expanded" : "0",
"level" : "Year",
"childrenCount" : "0",
"visibleChildrenCount" : "0",
"flags" : "0"
},
{
"k" : "4",
"id" : "OBJ4",
"n" : "Canada|A",
"vis" : "1",
"kind" : "Calculate",
"selectedUnit" : "",
"tag" : "",
"hasChildren" : "0",
"index" : "1",
"expanded" : "0",
"level" : "Year",
"childrenCount" : "0",
"visibleChildrenCount" : "0",
"flags" : "0"
},
{
"k" : "6",
"id" : "OBJ6",
"n" : "Russia|A",
"vis" : "1",
"kind" : "Calculate",
"selectedUnit" : "",
"tag" : "",
"hasChildren" : "0",
"index" : "2",
"expanded" : "0",
"level" : "Year",
"childrenCount" : "0",
"visibleChildrenCount" : "0",
"flags" : "0"
}
]
},
"displayDataAs" : "CalculatedValues",
"autoRecalc" : "1",
"createDerivedSeries" : "Default",
"permanentData" : "0"
},
"period" :
{
"start" : "1995-01-01",
"end" : "2015-01-01"
},
"rubrs" :
{
"def" :
{
"k" : "5472",
"id" : "TS_DB",
"n" : "Time series database",
"vis" : "1",
"rubId" :
{
"id" : "S1!M!S!W4!Rubs!5472"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "4",
"@hf" : "0",
"i" : "TS_DB",
"n" : "Time series database",
"k" : "5472",
"c" : "2822",
"p" : "5471",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"trackElementDependents" : "0",
"isPermanent" : "1",
"isTemp" : "0"
},
"openArgs" : ""
},
"period" :
{
"startYear" : "1980",
"endYear" : "2020"
}
}
},
"its" :
{
"it" :
[
{
"k" : "5472",
"id" : "TS_DB",
"n" : "Time series database",
"vis" : "1",
"rubId" :
{
"id" : "S1!M!S!W4!Rubs!5472"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "4",
"@hf" : "0",
"i" : "TS_DB",
"n" : "Time series database",
"k" : "5472",
"c" : "2822",
"p" : "5471",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"trackElementDependents" : "0",
"isPermanent" : "1",
"isTemp" : "0"
},
"openArgs" : ""
},
"period" :
{
"startYear" : "1980",
"endYear" : "2020"
}
}
}
]
}
}
}
}
}
public static OpenWbkResult OpenWbkForRead(MbId mb, string wbkId)
{
var tWbk = new OpenWbk()
{ // Set operation execution parameters
tArg = new OpenWbkArg()
{// Specify that open workbook for view
args = new WbkOpenArgs()
{
openForEdit = false
},// Set pattern for getting data
metaGet = new WbkMdPattern()
{
//viewMode = true, // view mode
series = ListOperation.Get, // data series
seriesFilter = new LnSeriesFilter()
{// Get collapsed series
includeCollapsed = true
},
period = true, // data display period parameters
rubrs = true, // data sources
rubrArg = new RubMdPattern() {period = true}
}
},// Specify workbook, with which execute operation
tOb = new OdId() { id = mb.id + "!" + FindObjectById(mb, wbkId).k }
};
// Create a proxy object for operation execution
var somClient = new SomPortTypeClient();
// Execute operation
var tResult = somClient.OpenWbk(tWbk);
Console.WriteLine("Workbook opened: " + tResult.id.id);
WbkMd openWbk = tResult.meta;
LnPeriod period = openWbk.period;
Console.WriteLine("Data display period:");
Console.WriteLine("".PadRight(3) + "- start: " + period.start.ToShortDateString());
Console.WriteLine("".PadRight(3) + "- end: " + period.end.ToShortDateString());
//Console.WriteLine("Workbook display mode: " + openWbk.viewMode.Value);
Console.WriteLine("Number of series: " + openWbk.series.count.ToString());
LnRubs rubrs = openWbk.rubrs;
Console.WriteLine("Identifier of default data source: " + rubrs.def.id);
Console.WriteLine("All data sources:");
foreach (LnRub rub in (rubrs.its))
{
Console.Write("".PadRight(3) + "- name '" + rub.n);
Console.WriteLine("'; identifier '" + rub.id + "'");
Console.WriteLine("".PadRight(6) + "calendar start: " + rub.meta.period.startYear.ToString());
Console.WriteLine("".PadRight(6) + "calendar end: " + rub.meta.period.endYear.ToString());
}
return tResult;
}
See also: