<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic I wasn't sure when writing my in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Excel-Fortran-interface-assistance/m-p/977807#M98966</link>
    <description>&lt;P&gt;I wasn't sure when writing my previous post, but if you know the name of the worksheet of interest you can simply index the Sheets collection with that.&amp;nbsp; Something along the lines of:&lt;/P&gt;
&lt;P&gt;[fortran]&amp;nbsp;&amp;nbsp;&amp;nbsp; USE IFCOM, etc...&lt;/P&gt;
&lt;P&gt;TYPE(VARIANT) :: name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ! Name of the desired sheet, as a variant&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; !***************************************************************************&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ! Construct variant with the desired worksheet name.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CALL VariantInit(name)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name%VT = VT_BSTR&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name%VU%PTR_VAL = ConvertStringToBSTR('NameOfInterest')&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ! Get the specific sheet.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; isheet = Sheets_GetItem(isheets, name, status)&lt;/P&gt;
&lt;P&gt;...&lt;BR /&gt;[/fortran]&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jun 2013 00:36:44 GMT</pubDate>
    <dc:creator>IanH</dc:creator>
    <dc:date>2013-06-03T00:36:44Z</dc:date>
    <item>
      <title>Excel/Fortran interface assistance</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Excel-Fortran-interface-assistance/m-p/977803#M98962</link>
      <description>&lt;P&gt;First my apologies for raising yet another Excel/Fortran thread I know there are numerous historic ones already and I have spent some time going through them.&amp;nbsp;Using the Autodice example in Composer XE 2013 and also taking some tips/code from the useful posts by Paul Curtis (thanks!) and others I have&amp;nbsp; managed&amp;nbsp; the implement a scheme to populate data from my Fortran application into a spreadsheet template which has a series of pre-prepared formats and charts. I have some useful utilities to insulate the hideousness of the interface from my working code and it seems to be working well so far.&lt;/P&gt;
&lt;P&gt;I have a couple of frustrating problems. I noticed during testing that if the active sheet in excel is a chart then we fail as there are no cells to populate in the worksheet object! I can trap the error and tell the user to go away and sort it out but something more friendly must be possible I think.&amp;nbsp;I can get the active worksheet object and interrogate the name of the sheet:&lt;/P&gt;
&lt;P&gt;[fortran]worksheet = $Workbook_GetActiveSheet(workbook, status)&lt;/P&gt;
&lt;P&gt;gbuf = $Application_GetName(worksheet, status) !get name of active sheet object - works!&amp;nbsp;[/fortran]&lt;/P&gt;
&lt;P&gt;It appears you can change the active sheet, however I can't see where you get a pointer to the sheet you actually want.&lt;/P&gt;
&lt;P&gt;[fortran]CALL&amp;nbsp;$Worksheet_Activate($OBJECT, status) !we can activate a specific sheet if we know the pointer to it!&amp;nbsp;[/fortran]&lt;/P&gt;
&lt;P&gt;Also you can enquire the sheet Names in the workbook, the code below has OK status and returns a pointer value but I do not know what data type is being pointed at or how the retrieve said data:&lt;/P&gt;
&lt;P&gt;[fortran]ifred = $Workbook_GetNames(workbook, status)&amp;nbsp;[/fortran]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;1] Does anyone have any insight into this area to give some tips?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;2] Also is there anywhere that gives some guidance on the use of the excel interface routines that are generated by the module wizard? There is some data on MSDN but it is quite hard to try to cross correlate and/or find information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Thanks In Advance,&amp;nbsp;Andrew&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jun 2013 18:37:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Excel-Fortran-interface-assistance/m-p/977803#M98962</guid>
      <dc:creator>andrew_4619</dc:creator>
      <dc:date>2013-06-01T18:37:47Z</dc:date>
    </item>
    <item>
      <title>I don't think Workbook</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Excel-Fortran-interface-assistance/m-p/977804#M98963</link>
      <description>&lt;P&gt;I don't think Workbook_GetNames returns sheet names.&amp;nbsp; I think it might return a collection of Name objects - the things created in Excel when you use the Ctrl-F3 keyboard shortcut (in the language versions I use anyway). &lt;/P&gt;
&lt;P&gt;Off the top of my head (not all of these are things that I have done or if I have done it, I've not looked to see how I've done it in my code, so I might be a bit off with them) - if you want to get the handle of a particular sheet, you could iterate throught the collection returned by Workbook_GetSheets and query the name (Worksheet_GetName).&amp;nbsp; If you want a particularly named sheet you may be able to query that directly via the Worksheets_GetItem method (use the name as an index).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My preferred way of operating is for the VBA code that calls the Fortran to pass in a worksheet handle, and then work directly with that - basically the client of the DLL decides what the DLL may scribble on.&lt;/P&gt;
&lt;P&gt;Changing the active sheet isn't required for most things - once you have a handle to a sheet or range you can just work with that.&lt;/P&gt;
&lt;P&gt;As for a reference - I used msdn with appropriate Fortran glasses on, combined with a lot of experimentation a while back to give a library of helper routines that work that I earnestly try not to break.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jun 2013 22:32:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Excel-Fortran-interface-assistance/m-p/977804#M98963</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2013-06-01T22:32:10Z</dc:date>
    </item>
    <item>
      <title>IanH: Many thanks for tips, I</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Excel-Fortran-interface-assistance/m-p/977805#M98964</link>
      <description>&lt;P&gt;IanH: Many thanks for tips, I have spent some more time beating my head further on this. The code below suggest the sheet information is in a VT_DISPATCH variant stucture but if so how do a get anything useful from this, what method/tool to use? Or perhaps more to the point how can I "&amp;nbsp;if you want to get the handle of a particular sheet, you could iterate throught the collection returned by Workbook_GetSheets.....". The answers are probably quite simple but I don't seem to be finding them!!&lt;/P&gt;
&lt;P&gt;[fortran]ibill=$Application_GetSheets(workbook, status) ! ibill is pointer to a collection of sheet objects?&lt;BR /&gt; call COMQUERYINTERFACE (ibill, IID_IUnknown , iinterface, status) !returns OK interface ptr returned = ibill, promising? &lt;BR /&gt; call COMQUERYINTERFACE (ibill, IID_IDispatch , ifred, status) !returns OK ifred set to point Presumably at a variant of type VT_DISPATCH?[/fortran]&lt;/P&gt;
&lt;P&gt;Any help would be greatrfully accepted! Andrew.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jun 2013 12:02:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Excel-Fortran-interface-assistance/m-p/977805#M98964</guid>
      <dc:creator>andrew_4619</dc:creator>
      <dc:date>2013-06-02T12:02:00Z</dc:date>
    </item>
    <item>
      <title>Having spent several hours</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Excel-Fortran-interface-assistance/m-p/977806#M98965</link>
      <description>&lt;P&gt;Having spent several hours looking at this problem the answer is very (embarrasingly) simple! Isn't it always. For the benefit of anyone that follows I have attached a code snipped that gets the handle of all the sheet objects in a workbook and gets the sheet name. As IanH pointed out the &amp;nbsp;sheet does need to be the active sheet to be able to write to it which is useful to know.&lt;/P&gt;
&lt;P&gt;[fortran]worksheet=0&lt;BR /&gt; isheets=$Workbook_GetSheets(workbook, status)&lt;BR /&gt; CALL VariantInit(vInt)&lt;BR /&gt; vInt%VT = VT_I4&lt;BR /&gt; do l1=1,20&lt;BR /&gt;&amp;nbsp; &amp;nbsp; vInt%VU%LONG_VAL = l1 !look at sheet no l1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; isheet=0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; isheet = Worksheets_GetItem(isheets, vInt, status) ! get handle for sheet l1 &lt;BR /&gt;&amp;nbsp; &amp;nbsp; if(status.ne.0 .or. isheet.eq.0 ) exit ! run out of sheets I guess&lt;BR /&gt;&amp;nbsp; &amp;nbsp; gbuf = $worksheet_GetName(isheet, status) ! get name of sheet object&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if(gsheet_i_want(1:lensht).eq.gbuf(1:lensht) ) then ! bingo found the sheet I want&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; worksheet=isheet&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;endif&lt;BR /&gt; enddo &lt;BR /&gt; status = VariantClear(vInt)[/fortran]&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jun 2013 15:38:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Excel-Fortran-interface-assistance/m-p/977806#M98965</guid>
      <dc:creator>andrew_4619</dc:creator>
      <dc:date>2013-06-02T15:38:00Z</dc:date>
    </item>
    <item>
      <title>I wasn't sure when writing my</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Excel-Fortran-interface-assistance/m-p/977807#M98966</link>
      <description>&lt;P&gt;I wasn't sure when writing my previous post, but if you know the name of the worksheet of interest you can simply index the Sheets collection with that.&amp;nbsp; Something along the lines of:&lt;/P&gt;
&lt;P&gt;[fortran]&amp;nbsp;&amp;nbsp;&amp;nbsp; USE IFCOM, etc...&lt;/P&gt;
&lt;P&gt;TYPE(VARIANT) :: name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ! Name of the desired sheet, as a variant&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; !***************************************************************************&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ! Construct variant with the desired worksheet name.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CALL VariantInit(name)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name%VT = VT_BSTR&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name%VU%PTR_VAL = ConvertStringToBSTR('NameOfInterest')&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ! Get the specific sheet.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; isheet = Sheets_GetItem(isheets, name, status)&lt;/P&gt;
&lt;P&gt;...&lt;BR /&gt;[/fortran]&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2013 00:36:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Excel-Fortran-interface-assistance/m-p/977807#M98966</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2013-06-03T00:36:44Z</dc:date>
    </item>
    <item>
      <title>Yes thanks Ian that is  a</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Excel-Fortran-interface-assistance/m-p/977808#M98967</link>
      <description>&lt;P&gt;Yes thanks Ian that is &amp;nbsp;a more efficent way and it works after correcting the typo (worksheet_getitem). I had tried something similar previously that failed to work but I am not sure what I did wrong as I have already tidied up the trial code. Anyway thanks for the assitance, wanting to keep all that Variant bstring rubbish out of my main code I integrated that option into a general "get a worksheet handle based on a number of different posible section criteria" (active, sheet number, sheet name etc)&amp;nbsp; routine.&lt;/P&gt;
&lt;P&gt;I think in retrospect one of the main problems is that the excel module has a large number of routines so it is not easy to find what you want or know what the capabilities/function of some of the routines are. A mixure of guess work, trial and error, MSDN and internet seaches is required. The reality is once you know what you are doing you can make a relatively small number of utility routines that do all that you want without having to have any understanding of the deeper workings of the interface and data structure...&lt;/P&gt;
&lt;P&gt;An overview and referance document from Intel would be a huge help to quite a number of Intel Fortran users but guess that would be quite a big task.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2013 09:24:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Excel-Fortran-interface-assistance/m-p/977808#M98967</guid>
      <dc:creator>andrew_4619</dc:creator>
      <dc:date>2013-06-03T09:24:38Z</dc:date>
    </item>
  </channel>
</rss>

