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

How to insert data into Excel sheet from VB.NET

Hi

When i clicked a button, i want to insert data from
listview in VB.NET to Excel sheet.
If you know the solution either above or below is ok for
me.
I know how to insert from a textfile,but all data of
textfile inserted into only into a single cell.I want to
insert single line of text file for each cell.
I tried to insert data into Excel sheet in many ways but
it will give some error when opening the Excel sheet.

data was inserted but when opening the sheet to view the
contents it gives error like this:

"Excel sheet was already opened"
but i never opened that sheet in before.

Here is the code i tried to insert into Excel sheet:

Dim fstr, mystr As String
Dim Index1, i, j As Integer
Dim ExcelWasNotRunning As Boolean
Dim str As String
Dim xlsWB As Object
Dim xlsPath, xlsFile, xlsTab As String

xlsWB = GetObject("D:\example.xls")

xlsWB.Parent.Windows(1).Visible = True

xlsWB.Application.Worksheets(xlsTab).Cells(3, 1) =
10
xlsWB.Application.Worksheets(xlsTab).Cells(3, 2)
= "C:\pagefile"
xlsWB.Application.Worksheets(xlsTab).Cells(4, 1) =
20
xlsWB.Application.Worksheets(xlsTab).Cells(4, 2)
= "D:\pagefile"
xlsWB.Application.Worksheets(xlsTab).Cells(5, 1) =
30
xlsWB.Application.Worksheets(xlsTab).Cells(5, 2)
= "E:\pagefile"

If any one knows please give me the solution

Mamatha
Nov 21 '05 #1
0 10372

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

Similar topics

14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
9
by: dba123 | last post by:
I need some help and direction on what classes and an example or two (article) on how to read an Excel Worksheet and insert one column into a database table column. I am using .NET 2.0 only. What...
0
by: imtmub | last post by:
Hi All, when i am trying to insert records from excel sheet to wko table in my database. My Excel sheet contains 400 records. I am getting the error message. please check this code and advise me. ...
1
by: pvenu | last post by:
Hi, I know basic perl (regular expressions, pattern matching, string manipulation, reading writing into text files). Yet, my requirement is to read an input text file -> process this input file...
6
by: poolboi | last post by:
hi all, i've got the following program that needs yr help: use Win32::OLE; # use existing instance if Excel is already running eval {$ex =...
7
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
3
kirubagari
by: kirubagari | last post by:
I would like to duplicate the numbers from from excel sheet 1 to excel sheet 2.Kindly help me on this.Sometime its unable to duplicate.. Sub Duplicate Dim oDoc As Object, oSheet As Object,...
1
kirubagari
by: kirubagari | last post by:
Hai experts, How to duplicate the data from 1 excel sheet to another excel sheet 2. Lets say Name Voucher Value Voucher Number lee 300.00 ...
1
by: PeacefulSoul | last post by:
Hello, I have a lot of excel sheets which columns are slightly different, i want to import all of these sheets (one at a time) into ONE SQL TABLE. I'll give an example : Say ive written the...
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: 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: 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,...
0
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,...

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.