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

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_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesbtnGetDoubles.Click
Dim colors(9) As String
Dim duoColorCollection 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
duoColorCollection.Add(colors(i) + "-" + colors(j))
inst.InstanceName = colors(i) + "-" + colors(j)
Next j
Next i

For Each inst.InstanceName In duoColorCollection ' Create list of names.
nameList &= inst.InstanceName & ControlChars.CrLf
Next

' Display the list of names in a label.
lblDoubles.Text = nameList
End Sub
Nov 20 '05 #1
2 1081
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_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesbtnGetDoubles.Click Dim colors(9) As String
Dim duoColorCollection 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
duoColorCollection.Add(colors(i) + "-" + colors(j))
inst.InstanceName = colors(i) + "-" + colors(j)
Next j
Next i

For Each inst.InstanceName In duoColorCollection ' Create list of names. nameList &= inst.InstanceName & ControlChars.CrLf
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 duoColorCollection 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.InstanceName = colors(i) + "-" + colors(j)

duoColorCollection.Add(inst)

Next j

Next i

ListBox1.DataSource = duoColorCollection

ListBox1.DisplayMember = "InstanceName"

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
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...
4
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...
4
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...
1
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 ...
3
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...
3
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...
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...
7
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...
3
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...
3
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'...
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
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...
0
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,...

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.