473,670 Members | 2,527 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Export Data to Spreadsheet

I have data that I need to either put in a spreadsheet, or use in a listview to view it. I would rather use the listview but I don't understand how to put my data into it. Here is the code I have, currently I am just display all the data in a label and it sucks.
Private Sub btnGetDoubles_C lick(ByVal sender As System.Object, ByVal e As System.EventArg s) HandlesbtnGetDo ubles.Click
Dim colors(9) As String
Dim duoColorCollect ion As New Collection
Dim nameList As String = ""
Dim oneInst As Class1
Dim intCounter As Integer

Dim i As Integer
Dim j As Integer
colors(0) = "Red"
colors(1) = "Green"
colors(2) = "Blue"
colors(3) = "Purple"
colors(4) = "White"
colors(5) = "Yellow"
colors(6) = "Brown"
colors(7) = "Orange"
colors(8) = "Black"
colors(9) = "Maroon"

Dim inst As New Class1

For i = 0 To colors.Length - 2
For j = i + 1 To colors.Length - 1
duoColorCollect ion.Add(colors( i) + "-" + colors(j))
inst.InstanceNa me = colors(i) + "-" + colors(j)
Next j
Next i

For Each inst.InstanceNa me In duoColorCollect ion ' Create list of names.
nameList &= inst.InstanceNa me & ControlChars.Cr Lf
Next

' Display the list of names in a label.
lblDoubles.Text = nameList
End Sub
Nov 20 '05 #1
2 1093
Cor
Hi Optik,

I see only one column, why not a listbox.
Than it is very easy when you use a datatabel.

But before I type it, has it to be one column?

Cor
I have data that I need to either put in a spreadsheet, or use in a listview to view it. I would rather use the listview but I don't understand
how to put my data into it. Here is the code I have, currently I am just
display all the data in a label and it sucks. Private Sub btnGetDoubles_C lick(ByVal sender As System.Object, ByVal e As System.EventArg s) HandlesbtnGetDo ubles.Click Dim colors(9) As String
Dim duoColorCollect ion As New Collection
Dim nameList As String = ""
Dim oneInst As Class1
Dim intCounter As Integer

Dim i As Integer
Dim j As Integer
colors(0) = "Red"
colors(1) = "Green"
colors(2) = "Blue"
colors(3) = "Purple"
colors(4) = "White"
colors(5) = "Yellow"
colors(6) = "Brown"
colors(7) = "Orange"
colors(8) = "Black"
colors(9) = "Maroon"

Dim inst As New Class1

For i = 0 To colors.Length - 2
For j = i + 1 To colors.Length - 1
duoColorCollect ion.Add(colors( i) + "-" + colors(j))
inst.InstanceNa me = colors(i) + "-" + colors(j)
Next j
Next i

For Each inst.InstanceNa me In duoColorCollect ion ' Create list of names. nameList &= inst.InstanceNa me & ControlChars.Cr Lf
Next

' Display the list of names in a label.
lblDoubles.Text = nameList
End Sub

Nov 20 '05 #2
Hi,

You can databind to a collection. You can show any property
contained in a class. Try this.

Dim colors(9) As String

Dim duoColorCollect ion As New Collection

Dim nameList As String = ""

Dim oneInst As Class1

Dim intCounter As Integer

Dim i As Integer

Dim j As Integer

colors(0) = "Red"

colors(1) = "Green"

colors(2) = "Blue"

colors(3) = "Purple"

colors(4) = "White"

colors(5) = "Yellow"

colors(6) = "Brown"

colors(7) = "Orange"

colors(8) = "Black"

colors(9) = "Maroon"

For i = 0 To colors.Length - 2

For j = i + 1 To colors.Length - 1

Dim inst As New class1

inst.InstanceNa me = colors(i) + "-" + colors(j)

duoColorCollect ion.Add(inst)

Next j

Next i

ListBox1.DataSo urce = duoColorCollect ion

ListBox1.Displa yMember = "InstanceNa me"

The class

Public Class class1

Dim m_strName As String

Public Property InstanceName() As String

Get

Return m_strName

End Get

Set(ByVal Value As String)

m_strName = Value

End Set

End Property

End Class

Ken

-----------------
Nov 20 '05 #3

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

Similar topics

0
864
by: Jason | last post by:
Can anyone point me to some sample code or tutorial that shows how I can export data from a database to an Excel spreadsheet that is already created on the server? I have an Excel spreadsheet that contains a number of labeled cells and sheets. When someone clicks the "Export to Excel" button on my asp page, I want to export the required data from my sql database to the Excel spreadsheet (putting the data in the appropriate cells and...
4
14774
by: Paolo | last post by:
Friends, I need help with some code to export different tables to a single spreadsheet in Excel. My excel file is named REPORT and the spreadsheet is named CLIENTS. I do have the code to export a single table to Excel but have problems with multimple tables. Thanks.
4
3126
by: Gary Wright | last post by:
I have an Access 2K database split into front and back. Quite often the users want to do some data analysis that I have not created a report for so they want to export some subset of the data into and Excel spreadsheet. Since the data often comes from many different tables, I have decided to create a temporary Access table, put all the data into it then use the Docmd.TransferSpreadsheet command to output the table to a spreadsheet. In...
1
2293
by: Ellen Manning | last post by:
I'm trying to export an Excel2K spreadsheet to A2K. Here is a sample of the Excel spreadsheet: LastName FirstName Hours Location HoursPercent Doe John 9 WMC 2.94 VA Med Ctr 265 VA 86.60 32 VA Res Clinic 10.45 <blank row>
3
11682
by: Scott M. Lyon | last post by:
I'm trying to figure out a way to export data (actually the result of a Stored Procedure call from SQL Server) into a specified Excel spreadsheet format. Currently, I have the data read into a DataSet that consists of one DataTable. That DataTable has a specific name (for arguments purposes, let's say it's called "DataGrid"), that I need to use as the tab name in the exported Excel
3
2440
by: Eddy | last post by:
I would like to export the output of 2 queries to excel namely: 1. QryProrationbyWBS_1 2. QryProrationbyWBS_2 However I want to do this using the same spreadsheet say sheet1 and sheet2 or better still with sheet name "ProrationWBS1" and "ProrationWBS2", how do I do this with acOutputQuery I have the following 2 commands attached to a command button:
1
9772
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...
7
28893
Merlin1857
by: Merlin1857 | last post by:
Its great producing data for users to look at in your web pages and generally that is sufficient for their needs but sometimes you may want to supply your user with the data in a form they can actually do something more with. This code shows you how to display data from your database and then how to give that data to the user in the form of a useable Excel spreadsheet which they can then take away and play with themselves. The way I have shown...
3
7546
by: jmarcrum | last post by:
I want to export a report (that contains two separate queries, 1. Current year data, and 2. split-year data) from access into excel, but everytime I run my code and export the data to excel, it looks like garbage. I have maximize and minimize buttons on the left side of the excel spreadsheet that I don't want. I want separate tabs on the bottom of the spreadsheet that show the two queries separately from one another. But I don't know how...
3
5435
by: =?Utf-8?B?TmV3YnJv?= | last post by:
Here's the long story short. At work we have to real-time generate a report(excel format) which involves a number of table joining. So to export into excel contentType 'application/vnd.ms-excel' is used, and data are written as table, looping each row of recordset data as table row. Problem is when user hit export and attempt to open/save the file, file would then be downloaded at constant rate. But during this time, entire server would...
0
8466
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
8896
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
8810
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...
1
8590
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7410
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
6211
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
4208
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2798
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
2
2035
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.