473,715 Members | 6,043 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3731
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.Applicati on
Dim xsheet As Workbook
Dim myArray(5) As String

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

' if not, open it
If o Is Nothing Then
o = CreateObject("E xcel.Applicatio n")
End If

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

xsheet = o.Workbooks.Ope n(FileName:="so mefilenameandpa th")
xsheet.Applicat ion.Visible = True
' run the subroutine you want
xsheet.Applicat ion.Run("Routin eName_FileRange ", myArray)

HTH
Steve
<mi*********@bi gpond.comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.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*********@big pond.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*********@big pond.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*********@big pond.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
5031
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. Before I iterate through the recordset I instruct the browser that the content type is Excel using the following line: (Response.ContentType = "application/vnd.ms-excel") This works fine with Excel 2003 but with older versions (I tested Excel...
2
1638
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 exporting using a lower version and it works but then the memo fields are truncated. How can I fix this, or how can I export to excel using another method so these aposts. are not there.
4
12036
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 string array of data to a range in excel (similar to a copyfromrecordset). However, with this approach, the datatype is lost and all numeric columns in excel appear as string. In order to overcome this, I tried calling TextToColumns on each...
5
2671
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 is done. I am using the following .NET code in my Com Class object: <ComClass(DIF2XLS.ClassId, DIF2XLS.InterfaceId, DIF2XLS.EventsId)> _ Public Class DIF2XLS #Region "COM GUIDs"
4
15010
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 exporting dataset data to an excel using the Excel COM object. This works fine but the problem is its pretty darn slow when exporting large
13
13231
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" HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=ABC.xls") HttpContext.Current.Response.Write(strHTML) HttpContext.Current.Response.End() However when the user tries to save it the Default File Type is Web Page(*.htm; *.html)
5
31921
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
9777
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 having I'd be most appreciative. The database is already constructed, I'm just wanting to export the data to an excel file. In short, I'm hoping to export two Tables (or queries...not sure which to use - they both seem to have the same data) in...
2
6413
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 method.... it creates 6 sheets # region Namespaces using System;
0
8821
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9340
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9196
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7973
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6646
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5967
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3175
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
3
2118
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.