How to connect with Excel (via OLE)

This forum is meant for questions and discussions about the X# language and tools
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

How to connect with Excel (via OLE)

Post by Karl-Heinz »

Hi Chris,

i´m wondering what the "Namespace:" sle content is used for ? The "Name:" content is the name of the subdir to create, and the assembly name to create is always "excel.dll". The "Namespace:" sle may not be empty, but i don´t see where a content like "dfhjjkhhlkkk" is used. Neither becomes the name of the dll "dfhjjkhhlkkk.dll" nor do i see anywhere in the created dll a reference to "dfhjjkhhlkkk" ?

regards
Karl-Heinz
User avatar
Chris
Posts: 4913
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

How to connect with Excel (via OLE)

Post by Chris »

Hi Karl-Heinz,
Karl-Heinz wrote: i´m wondering what the "Namespace:" sle content is used for ? The "Name:" content is the name of the subdir to create, and the assembly name to create is always "excel.dll". The "Namespace:" sle may not be empty, but i don´t see where a content like "dfhjjkhhlkkk" is used. Neither becomes the name of the dll "dfhjjkhhlkkk.dll" nor do i see anywhere in the created dll a reference to "dfhjjkhhlkkk" ?
I was wondering the same thing during my tests in the last couple days! :)

What the IDE does, is to supply tlbimp.exe with a parameter /namespace:<namespace> command line option when calling it, I am pretty sure this worked at some time in the past and I think it was actually mandatory to specify the namespace. But indeed, I see now it gets ignored...

Or maybe it's just specific to the Office interop libraries, maybe because those are already created somewhere in the machine (hence the warning), the tool does not really generate a new one, but just makes a copy of the existing one. Pure speculation, but I am saying that because I just tested it with other COM libs, and I see the namespace parameter is being respected with them..

Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

How to connect with Excel (via OLE)

Post by Karl-Heinz »

Hi Chris,

i´ve tried it with a com dll that i´m using to read/write excel files in VO, and the given Namespace is correctly written to the dll.

BTW. Til now i ignored this warning if a excel.dll is created:

TlbImp : warning TI3001 : Primary interop assembly 'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C' is already registered for type library 'C:Program FilesMicrosoft Office 15RootOffice15EXCEL.EXE'.

I didn´t dive in deeper, but maybe indicates such a warning that a given namespace is ignored ?

regards
Karl-Heinz
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

How to connect with Excel (via OLE)

Post by Karl-Heinz »

Hi Chris,

I think it's not necessary to open a new thread, because my question about "using and alias names" fits well with Excel.

In a earlier thread i found the hint how to give a namespace an alias

https://www.xsharp.eu/forum/public-prod ... de?start=0

but i can´t get it to work.

Code: Select all



// USING Excel := Microsoft.Office.Interop.Excel
USING ExcelAlias := Microsoft.Office.Interop.Excel
  

FUNCTION Start() AS VOID 
	
// LOCAL oWorkbooks AS Excel.Workbooks   // error
LOCAL oWorkbooks AS ExcelAlias.Workbooks  // error


// This compiles 
// LOCAL oWorkbooks AS Microsoft.Office.Interop.Excel.Workbooks

wait


RETURN 


It ends up that the namespace "ExcelAlias" or "Excel" can´t be found. Must i set e.g. any specific compiler switches to make it work ?

regards
Karl-Heinz
User avatar
Chris
Posts: 4913
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

How to connect with Excel (via OLE)

Post by Chris »

Hi Karl-Heinz,

Thanks, this looks like a bug to me, will log a report about this. Can't think of a workaround unfortunately, unless Robert has an idea.

About tlbimp, yeah, that was my thought, too, that the warning implies that actually no real new dll is created, it just copies the already existing one with the original namepsace, so your namespace gets ignored as well.

Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply