Opening Workbook for Read

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.

SOAP request:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<OpenWbk xmlns="http://www.fsight.ru/PP.SOM.Som">
<tOb xmlns="">
  <id>S1!M!5505</id>
  </tOb>
<tArg xmlns="">
<args>
  <openForEdit>false</openForEdit>
  </args>
<metaGet>
  <obInst>true</obInst>
  <useGridAutoAdjust>true</useGridAutoAdjust>
  <series>Get</series>
<seriesFilter>
  <includeCollapsed>true</includeCollapsed>
  </seriesFilter>
  <period>true</period>
  <rubrs>true</rubrs>
<rubrArg>
  <obInst>true</obInst>
  <period>true</period>
  </rubrArg>
  </metaGet>
  </tArg>
  </OpenWbk>
  </s:Body>
  </s:Envelope>

SOAP response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<OpenWbkResult xmlns="http://www.fsight.ru/PP.SOM.Som" xmlns:q1="http://www.fsight.ru/PP.SOM.Som" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<id xmlns="">
  <id>S1!M!S!W4</id>
  </id>
<meta xmlns="">
<obInst>
<obDesc ds="" isShortcut="0" isLink="0" ver="1" hf="0">
  <i>WBK_AD</i>
  <n>Annual data</n>
  <k>5505</k>
  <c>2827</c>
  <p>5471</p>
  <h>0</h>
  <hasPrv>0</hasPrv>
  <ic>0</ic>
  <trackElementDependents>0</trackElementDependents>
  <isPermanent>1</isPermanent>
  <isTemp>0</isTemp>
  </obDesc>
  <openArgs />
  </obInst>
  <windowsPosition>Vertical</windowsPosition>
  <hasPivot>0</hasPivot>
  <hasLaner>1</hasLaner>
<series count="3">
<its>
<it>
  <k>2</k>
  <id>OBJ2</id>
  <n>USA|A</n>
  <vis>1</vis>
  <kind>Calculate</kind>
  <selectedUnit />
  <tag />
  <hasChildren>0</hasChildren>
  <index>0</index>
  <expanded>0</expanded>
  <level>Year</level>
  <childrenCount>0</childrenCount>
  <visibleChildrenCount>0</visibleChildrenCount>
  <flags>0</flags>
  </it>
<it>
  <k>4</k>
  <id>OBJ4</id>
  <n>Canada|A</n>
  <vis>1</vis>
  <kind>Calculate</kind>
  <selectedUnit />
  <tag />
  <hasChildren>0</hasChildren>
  <index>1</index>
  <expanded>0</expanded>
  <level>Year</level>
  <childrenCount>0</childrenCount>
  <visibleChildrenCount>0</visibleChildrenCount>
  <flags>0</flags>
  </it>
<it>
  <k>6</k>
  <id>OBJ6</id>
  <n>Russia|A</n>
  <vis>1</vis>
  <kind>Calculate</kind>
  <selectedUnit />
  <tag />
  <hasChildren>0</hasChildren>
  <index>2</index>
  <expanded>0</expanded>
  <level>Year</level>
  <childrenCount>0</childrenCount>
  <visibleChildrenCount>0</visibleChildrenCount>
  <flags>0</flags>
  </it>
  </its>
  <displayDataAs>CalculatedValues</displayDataAs>
  <autoRecalc>1</autoRecalc>
  <createDerivedSeries>Default</createDerivedSeries>
  <permanentData>0</permanentData>
  </series>
<period>
  <start>1995-01-01</start>
  <end>2015-01-01</end>
  </period>
<rubrs>
<def>
  <k>5472</k>
  <id>TS_DB</id>
  <n>Time series database</n>
  <vis>1</vis>
<rubId>
  <id>S1!M!S!W4!Rubs!5472</id>
  </rubId>
<meta>
<obInst>
<obDesc ds="" isShortcut="0" isLink="0" ver="4" hf="0">
  <i>TS_DB</i>
  <n>Time series database</n>
  <k>5472</k>
  <c>2822</c>
  <p>5471</p>
  <h>0</h>
  <hasPrv>0</hasPrv>
  <ic>0</ic>
  <trackElementDependents>0</trackElementDependents>
  <isPermanent>1</isPermanent>
  <isTemp>0</isTemp>
  </obDesc>
  <openArgs />
  </obInst>
<period>
  <startYear>1980</startYear>
  <endYear>2020</endYear>
  </period>
  </meta>
  </def>
<its>
<it>
  <k>5472</k>
  <id>TS_DB</id>
  <n>Time series database</n>
  <vis>1</vis>
<rubId>
  <id>S1!M!S!W4!Rubs!5472</id>
  </rubId>
<meta>
<obInst>
<obDesc ds="" isShortcut="0" isLink="0" ver="4" hf="0">
  <i>TS_DB</i>
  <n>Time series database</n>
  <k>5472</k>
  <c>2822</c>
  <p>5471</p>
  <h>0</h>
  <hasPrv>0</hasPrv>
  <ic>0</ic>
  <trackElementDependents>0</trackElementDependents>
  <isPermanent>1</isPermanent>
  <isTemp>0</isTemp>
  </obDesc>
  <openArgs />
  </obInst>
<period>
  <startYear>1980</startYear>
  <endYear>2020</endYear>
  </period>
  </meta>
  </it>
  </its>
  </rubrs>
  </meta>
  </OpenWbkResult>
  </soapenv:Body>
  </soapenv:Envelope>

JSON request:

{
"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"
}
}
}
}
}

JSON response:

{
"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:

OpenWbk: Operation