473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 programmatically populate the excel sheet cells, but I
would like to avoid this. I'm thinking something like this:

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

then within excel, I have cell references:
=object1.GetValue(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 2061
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.com

"frankplank" <fr**********@yahoo.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.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 programmatically populate the excel sheet cells, but I
would like to avoid this. I'm thinking something like this:

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

then within excel, I have cell references:
=object1.GetValue(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("TotalRevenuesWeek2").

Originally, I was hoping to programmatically 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.com

"frankplank" <fr**********@yahoo.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.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 programmatically populate the excel sheet cells, but I would like to avoid this. I'm thinking something like this:

object1:
DataArray[][] ...;
GetValue(StringVal) ; // get value of data array, based on string
then within excel, I have cell references:
=object1.GetValue(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**********@yahoo.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.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("TotalRevenuesWeek2").

Originally, I was hoping to programmatically 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.com

"frankplank" <fr**********@yahoo.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.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 programmatically populate the excel sheet cells, but I would like to avoid this. I'm thinking something like this:

object1:
DataArray[][] ...;
GetValue(StringVal) ; // get value of data array, based on string
then within excel, I have cell references:
=object1.GetValue(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**********@yahoo.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.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("TotalRevenuesWeek2").

Originally, I was hoping to programmatically 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.com

"frankplank" <fr**********@yahoo.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.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 programmatically populate the excel sheet cells,
but I
> would like to avoid this. I'm thinking something like this:
>
> object1:
> DataArray[][] ...;
> GetValue(StringVal) ; // get value of data array, based on

string
>
> then within excel, I have cell references:
> =object1.GetValue(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**********@yahoo.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.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**********@yahoo.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.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("TotalRevenuesWeek2").

Originally, I was hoping to programmatically 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.com
>
> "frankplank" <fr**********@yahoo.com> wrote in message
> news:11*********************@l41g2000cwc.googlegro ups.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 programmatically populate the excel sheet cells, but I
> > would like to avoid this. I'm thinking something like this:
> >
> > object1:
> > DataArray[][] ...;
> > GetValue(StringVal) ; // get value of data array, based on
string
> >
> > then within excel, I have cell references:
> > =object1.GetValue(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**********@yahoo.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.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 programmatically populate the excel sheet cells, but I
would like to avoid this. I'm thinking something like this:

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

then within excel, I have cell references:
=object1.GetValue(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
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)...
0
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...
5
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. ...
4
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 ...... ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

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.