473,386 Members | 1,819 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,386 software developers and data experts.

Export array from vb.net to excel

Can anyone help me. I wish to export an array from vb.net to excel
ranges. This will happen for multiple files. The ranges names will not
be start and end in the same cells on all files. How do i do this?

Sep 28 '06 #1
5 3710
One way to do this is to write a subroutine in your Excel spreadsheet that
takes either an object or variant as a parameter, convert the object to a
string array and input your values from the array into the range that you
wish. I've done this in VB6 but not .NET. It looks like it should work in
..Net as well. Just include a reference to the Microsoft Excel Object library
(whatever version that's on your machine and the target machines). Then do
something like this:

Dim o As Excel.Application
Dim xsheet As Workbook
Dim myArray(5) As String

' is Excel already open?
o = GetObject(, "Excel.Application")

' if not, open it
If o Is Nothing Then
o = CreateObject("Excel.Application")
End If

For i As Integer = 0 To myArray.GetUpperBound(0)
myArray(i) = i.ToString()
Next

xsheet = o.Workbooks.Open(FileName:="somefilenameandpath")
xsheet.Application.Visible = True
' run the subroutine you want
xsheet.Application.Run("RoutineName_FileRange", myArray)

HTH
Steve
<mi*********@bigpond.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Can anyone help me. I wish to export an array from vb.net to excel
ranges. This will happen for multiple files. The ranges names will not
be start and end in the same cells on all files. How do i do this?

Sep 28 '06 #2
http://www.kjmsolutions.com/datasetarray.htm
mi*********@bigpond.com wrote:
Can anyone help me. I wish to export an array from vb.net to excel
ranges. This will happen for multiple files. The ranges names will not
be start and end in the same cells on all files. How do i do this?
Sep 28 '06 #3
http://www.kjmsolutions.com/datasetarray.htm
mi*********@bigpond.com wrote:
Can anyone help me. I wish to export an array from vb.net to excel
ranges. This will happen for multiple files. The ranges names will not
be start and end in the same cells on all files. How do i do this?
Sep 28 '06 #4
Thanks for the replies but I will not be haing a reference to Excel at
all.

Sep 28 '06 #5
Hi Micheal

If you're not having any references to Excel then I don't imagine
you're going to be able to do this as ranges and names are Excel
specific so unless you are familiar with the Excel file format and are
comfortable creating files in this format (or you're using a version of
Excel that uses an XML file format) then you're left with the choice of
buying/using an Excel component (Aspose for example) or referencing
Excel.

HTH
Martin

mi*********@bigpond.com wrote:
Thanks for the replies but I will not be haing a reference to Excel at
all.
Sep 29 '06 #6

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

Similar topics

1
by: Matt | last post by:
I have an ASP page that calls ASP routines that I created that execute a database query and return the results to a recordset. I then iterate through the recordset and display the data in a table....
2
by: Danny | last post by:
I am trying to export my access 2002 table to excel using transfer spreadsheet. It works fine but in excel, there is an apostrophe before each word in all cells. How can I avoid this? I tried...
4
by: John Z. | last post by:
I have read numerous articles and postings on various approaches to exporting a DataSet to excel while avoiding the use of automation. I found the most performant approach to be assigning a...
5
by: Tim Frawley | last post by:
I created a .NET Com Class object for use in ASP reports to export database results directly to Excel. I have it all working just find but I cannot get the Excel process to go away after the job...
4
by: Jiro Hidaka | last post by:
Hello, I would like to know of a fast way to export data source data into an Excel sheet. I found a way from C# Corner(Query Tool to Excel using C# and .NET) which is a neat little way of...
13
by: Hemant Sipahimalani | last post by:
The following piece of code is being used to export HTML to excel. HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"...
5
by: Simon | last post by:
Dear reader, With the export command you can export a query to Excel. By activate this command a form pop's up with the following text:
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
2
hemantbasva
by: hemantbasva | last post by:
Note We need to have a template on server for generating report in multiple sheet as we do not had msoffice on server moreover this require a batch job to delete excel file created by the...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.