473,545 Members | 937 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reference C# object from within Excel

Hi *,
I'm wondering if it is possible to create a C# object, and reference it
*explicitly* in an excel document. I imagine this will be more
possible if I programmaticall y populate the excel sheet cells, but I
would like to avoid this. I'm thinking something like this:

object1:
DataArray[][] ...;
GetValue(String Val) ; // get value of data array, based on string

then within excel, I have cell references:
=object1.GetVal ue(StringValA)

----------------------------------

Also, if this is possible, I wonder how I trigger the creation of the
object's data values, which would be read from a delimited file.

Thanks very much,
Frank

Nov 16 '05 #1
6 2074
Frank,

Do you mean you want to connect to a running instance of a .NET object,
or you want to create a .NET object in Excel? If the answer is the latter,
then you can access most .NET objects through COM interop. Check out the
section of the .NET documentation titled "Exposing .NET Framework Components
to COM", located at (watch for line wrap):

http://msdn.microsoft.com/library/de...cominterop.asp

If the answer is the former, you might want to use a web service (a bit
of overkill), or a serviced component (COM+).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"frankplank " <fr**********@y ahoo.com> wrote in message
news:11******** *************@l 41g2000cwc.goog legroups.com...
Hi *,
I'm wondering if it is possible to create a C# object, and reference it
*explicitly* in an excel document. I imagine this will be more
possible if I programmaticall y populate the excel sheet cells, but I
would like to avoid this. I'm thinking something like this:

object1:
DataArray[][] ...;
GetValue(String Val) ; // get value of data array, based on string

then within excel, I have cell references:
=object1.GetVal ue(StringValA)

----------------------------------

Also, if this is possible, I wonder how I trigger the creation of the
object's data values, which would be read from a delimited file.

Thanks very much,
Frank

Nov 16 '05 #2
Hi Nicholas,
Thanks for your response. I would say I am interested more in the
latter. To put it briefly, I'm in a situation where I have an existing
automated reporting (excel based) system that pulls it's source data
from a delimited file into a worksheet. The references (for
calculations, charts, etc.) within the worksheet are all dependent on
the cell position in excel, which is all dependent on the format of the
delimited file. So, when the file format changes, all the references
need to be shifted by 1 (or more)manually.

My idea is to put a middle layer (.net object) that reads the delimited
file, internally maps the values by a more useful type, and then
exposes the data structure to a callable function to the worksheet. So
instead of referencing (for example) =C1, I would use
=GetVal("TotalR evenuesWeek2").

Originally, I was hoping to programmaticall y populate the whole excel
workbook through C#, but specifying the chart looked rather ghastly.

Thanks, Frank

Nicholas Paldino [.NET/C# MVP] wrote:
Frank,

Do you mean you want to connect to a running instance of a .NET object, or you want to create a .NET object in Excel? If the answer is the latter, then you can access most .NET objects through COM interop. Check out the section of the .NET documentation titled "Exposing .NET Framework Components to COM", located at (watch for line wrap):

http://msdn.microsoft.com/library/de...cominterop.asp
If the answer is the former, you might want to use a web service (a bit of overkill), or a serviced component (COM+).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"frankplank " <fr**********@y ahoo.com> wrote in message
news:11******** *************@l 41g2000cwc.goog legroups.com...
Hi *,
I'm wondering if it is possible to create a C# object, and reference it *explicitly* in an excel document. I imagine this will be more
possible if I programmaticall y populate the excel sheet cells, but I would like to avoid this. I'm thinking something like this:

object1:
DataArray[][] ...;
GetValue(String Val) ; // get value of data array, based on string
then within excel, I have cell references:
=object1.GetVal ue(StringValA)

----------------------------------

Also, if this is possible, I wonder how I trigger the creation of the object's data values, which would be read from a delimited file.

Thanks very much,
Frank


Nov 16 '05 #3
Hi

I think you want to know about Automation Add-ins.
http://www.codeproject.com/dotnet/excelnetauto.asp

Best Regards,
Fredrik
"frankplank " <fr**********@y ahoo.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Hi Nicholas,
Thanks for your response. I would say I am interested more in the
latter. To put it briefly, I'm in a situation where I have an existing
automated reporting (excel based) system that pulls it's source data
from a delimited file into a worksheet. The references (for
calculations, charts, etc.) within the worksheet are all dependent on
the cell position in excel, which is all dependent on the format of the
delimited file. So, when the file format changes, all the references
need to be shifted by 1 (or more)manually.

My idea is to put a middle layer (.net object) that reads the delimited
file, internally maps the values by a more useful type, and then
exposes the data structure to a callable function to the worksheet. So
instead of referencing (for example) =C1, I would use
=GetVal("TotalR evenuesWeek2").

Originally, I was hoping to programmaticall y populate the whole excel
workbook through C#, but specifying the chart looked rather ghastly.

Thanks, Frank

Nicholas Paldino [.NET/C# MVP] wrote:
Frank,

Do you mean you want to connect to a running instance of a .NET

object,
or you want to create a .NET object in Excel? If the answer is the

latter,
then you can access most .NET objects through COM interop. Check out

the
section of the .NET documentation titled "Exposing .NET Framework

Components
to COM", located at (watch for line wrap):

http://msdn.microsoft.com/library/de...cominterop.asp

If the answer is the former, you might want to use a web service

(a bit
of overkill), or a serviced component (COM+).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"frankplank " <fr**********@y ahoo.com> wrote in message
news:11******** *************@l 41g2000cwc.goog legroups.com...
Hi *,
I'm wondering if it is possible to create a C# object, and reference it *explicitly* in an excel document. I imagine this will be more
possible if I programmaticall y populate the excel sheet cells, but I would like to avoid this. I'm thinking something like this:

object1:
DataArray[][] ...;
GetValue(String Val) ; // get value of data array, based on string
then within excel, I have cell references:
=object1.GetVal ue(StringValA)

----------------------------------

Also, if this is possible, I wonder how I trigger the creation of the object's data values, which would be read from a delimited file.

Thanks very much,
Frank



Nov 16 '05 #4
Hello,
Thanks for your response. Can automation add-ins be used on Excel
2002, for Windows 2000 ? This article suggests it is only available
for 2002 on XP. Thanks, Frank
Fredrik Wahlgren wrote:
Hi

I think you want to know about Automation Add-ins.
http://www.codeproject.com/dotnet/excelnetauto.asp

Best Regards,
Fredrik
"frankplank " <fr**********@y ahoo.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Hi Nicholas,
Thanks for your response. I would say I am interested more in the
latter. To put it briefly, I'm in a situation where I have an existing automated reporting (excel based) system that pulls it's source data from a delimited file into a worksheet. The references (for
calculations, charts, etc.) within the worksheet are all dependent on the cell position in excel, which is all dependent on the format of the delimited file. So, when the file format changes, all the references need to be shifted by 1 (or more)manually.

My idea is to put a middle layer (.net object) that reads the delimited file, internally maps the values by a more useful type, and then
exposes the data structure to a callable function to the worksheet. So instead of referencing (for example) =C1, I would use
=GetVal("TotalR evenuesWeek2").

Originally, I was hoping to programmaticall y populate the whole excel workbook through C#, but specifying the chart looked rather ghastly.
Thanks, Frank

Nicholas Paldino [.NET/C# MVP] wrote:
Frank,

Do you mean you want to connect to a running instance of a ..NET
object,
or you want to create a .NET object in Excel? If the answer is
the latter,
then you can access most .NET objects through COM interop. Check
out the
section of the .NET documentation titled "Exposing .NET Framework

Components
to COM", located at (watch for line wrap):

http://msdn.microsoft.com/library/de...cominterop.asp
If the answer is the former, you might want to use a web service
(a bit
of overkill), or a serviced component (COM+).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"frankplank " <fr**********@y ahoo.com> wrote in message
news:11******** *************@l 41g2000cwc.goog legroups.com...
> Hi *,
> I'm wondering if it is possible to create a C# object, and

reference it
> *explicitly* in an excel document. I imagine this will be more
> possible if I programmaticall y populate the excel sheet cells,
but I
> would like to avoid this. I'm thinking something like this:
>
> object1:
> DataArray[][] ...;
> GetValue(String Val) ; // get value of data array, based on

string
>
> then within excel, I have cell references:
> =object1.GetVal ue(StringValA)
>
> ----------------------------------
>
> Also, if this is possible, I wonder how I trigger the creation
of the
> object's data values, which would be read from a delimited

file. >
> Thanks very much,
> Frank
>



Nov 16 '05 #5
Yes. Only the version of Excel matters.

/Fredrik

"frankplank " <fr**********@y ahoo.com> wrote in message
news:11******** **************@ l41g2000cwc.goo glegroups.com.. .
Hello,
Thanks for your response. Can automation add-ins be used on Excel
2002, for Windows 2000 ? This article suggests it is only available
for 2002 on XP. Thanks, Frank
Fredrik Wahlgren wrote:
Hi

I think you want to know about Automation Add-ins.
http://www.codeproject.com/dotnet/excelnetauto.asp

Best Regards,
Fredrik
"frankplank " <fr**********@y ahoo.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Hi Nicholas,
Thanks for your response. I would say I am interested more in the
latter. To put it briefly, I'm in a situation where I have an existing automated reporting (excel based) system that pulls it's source data from a delimited file into a worksheet. The references (for
calculations, charts, etc.) within the worksheet are all dependent on the cell position in excel, which is all dependent on the format of the delimited file. So, when the file format changes, all the references need to be shifted by 1 (or more)manually.

My idea is to put a middle layer (.net object) that reads the delimited file, internally maps the values by a more useful type, and then
exposes the data structure to a callable function to the worksheet. So instead of referencing (for example) =C1, I would use
=GetVal("TotalR evenuesWeek2").

Originally, I was hoping to programmaticall y populate the whole excel workbook through C#, but specifying the chart looked rather ghastly.
Thanks, Frank

Nicholas Paldino [.NET/C# MVP] wrote:
> Frank,
>
> Do you mean you want to connect to a running instance of a .NET object,
> or you want to create a .NET object in Excel? If the answer is the latter,
> then you can access most .NET objects through COM interop. Check out the
> section of the .NET documentation titled "Exposing .NET Framework
Components
> to COM", located at (watch for line wrap):
>
>

http://msdn.microsoft.com/library/de...cominterop.asp
>
> If the answer is the former, you might want to use a web service (a bit
> of overkill), or a serviced component (COM+).
>
> Hope this helps.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mv*@spam.guard. caspershouse.co m
>
> "frankplank " <fr**********@y ahoo.com> wrote in message
> news:11******** *************@l 41g2000cwc.goog legroups.com...
> > Hi *,
> > I'm wondering if it is possible to create a C# object, and
reference it
> > *explicitly* in an excel document. I imagine this will be more
> > possible if I programmaticall y populate the excel sheet cells, but I
> > would like to avoid this. I'm thinking something like this:
> >
> > object1:
> > DataArray[][] ...;
> > GetValue(String Val) ; // get value of data array, based on
string
> >
> > then within excel, I have cell references:
> > =object1.GetVal ue(StringValA)
> >
> > ----------------------------------
> >
> > Also, if this is possible, I wonder how I trigger the creation of the
> > object's data values, which would be read from a delimited file. > >
> > Thanks very much,
> > Frank
> >



Nov 16 '05 #6
Hello Frank,

have a look at this:

http://www.managedxll.net/excel/net/...s.example.html

Best regards,
Jens.

--
http://ManagedXLL.net/
Replace MSDN with my first name when replying to my email address!

"frankplank " <fr**********@y ahoo.com> wrote in message
news:11******** *************@l 41g2000cwc.goog legroups.com...
Hi *,
I'm wondering if it is possible to create a C# object, and reference it
*explicitly* in an excel document. I imagine this will be more
possible if I programmaticall y populate the excel sheet cells, but I
would like to avoid this. I'm thinking something like this:

object1:
DataArray[][] ...;
GetValue(String Val) ; // get value of data array, based on string

then within excel, I have cell references:
=object1.GetVal ue(StringValA)

----------------------------------

Also, if this is possible, I wonder how I trigger the creation of the
object's data values, which would be read from a delimited file.

Thanks very much,
Frank

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
633
by: Ronny Sigo | last post by:
Hello all, Could anybody help me referencing individual cells in excel? I don't know what I do wrong here (but I'm not familiar with excel vba) (Microsoft Excel 10.0 Object library is referenced) Any help very much appreciated Thanks Ronny Private Sub btnTargetAffGroupEmailImport_Click() Dim MyXL As Object
0
1037
by: pshipway9[snipATsnip]yahoo.com | last post by:
I can't get vb.net to create a new Excel.Application object. MS Development Environment 7.1.3088 Net Framework 1.1 Office 2003 I understand the DIM exl as new Excel.Application stuff. I think I've got a reference problem. When I add reference: Microsoft Excel 11.0 object Library, VB doesn't recognize "new Excel.Application" - doesn't
5
49780
by: Michael Russell | last post by:
Hi all, Using C#, I've created a simple wrapper class for using Excel. I have Office Pro 2003 installed on my devel machine. The wrapper class works great, reading and writing to/from Excel. To do this, I created a reference to "Microsoft Excel 11.0 Object Library", and have a "using Excel;" directive. I decided to add a method for...
4
11579
by: Looch | last post by:
Thanks in advance for any help. I'm having trouble with this code: Dim xlsApp As Excel.Application Dim xlsWB As Excel.Workbook xlsApp = New Excel.Application xlsApp.Visible = True ...... The problem is Excel.Application is not recognized. I have the Excell
0
7401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7419
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4944
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1879
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
703
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.