473,385 Members | 1,292 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.

Excel Report in VB.NET

Hi,

I am trying to generate Excel sheet using
Provider=Microsoft.Jet.OLEDB.4.0;

I am always getting the error while inserting data into any cell other
than A.

An unhandled exception of type 'System.Data.OleDb.OleDbException'
occurred in system.data.dll

I am greatful to you if anyone could correct this. Also appreciate if
you can give me info about this kind of excel report generation in
VB.NET.

My OS id windows XP pro, using Excel 2000.

Here is my code:
I am using c:\temp\show.xml which is blank excel file with excel sheet
name iPOS. And also created a folder c:\temp\iPOSReports

Pls help to resolve this issue.

Imports System.Data.OleDb
Imports System.IO

Module Module1

Private excelConn As OleDbConnection
Private excelComm As OleDbCommand
Private excelConnStr As String
Private fso As File
Private desPath As String

Sub Main()
Dim sqlStr As String
Dim des As String = "show" & Now.Month & Now.Day & Now.Year &
Now.Hour & Now.Minute & Now.Second & ".xls"
desPath = "c:\temp\iPOSReports\" & des
fso.Copy("c:\temp\show.xls", desPath)
fso = Nothing
Dim cnt As Integer
For cnt = 0 To 10
sqlStr = "Insert Into [iPOS$A" & cnt & ":A" & cnt & "]
Values ('Kiran here');"
executeSql(sqlStr)
Next
Return
End Sub

Private Sub InitializeConnection()
excelConn = New OleDbConnection
excelConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & desPath & ";Extended
Properties=""Excel 8.0;HDR=YES"""
End Sub
Private Sub EstablishConnection()
excelConn.ConnectionString = excelConnStr
excelConn.Open()
End Sub
Private Sub executeSql(ByVal sqlStr As String)
InitializeConnection()
EstablishConnection()
excelComm = New OleDbCommand
excelComm.CommandType = CommandType.Text
excelComm.CommandText = sqlStr
excelComm.Connection = excelConn
excelComm.ExecuteNonQuery()
MsgBox(sqlStr)
closeConnection()
End Sub
Private Sub closeConnection()
excelComm.Dispose()
excelComm = Nothing
excelConn.Close()
excelConn = Nothing
End Sub

End Module

Jul 21 '05 #1
0 1166

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

Similar topics

3
by: Spacy | last post by:
Am creating a HTML Report in asp.net. To save this report to excel on client-side, i write this code: Response.ContentType = "application/vnd.ms-excel" Response.AddHeader("content-disposition",...
1
by: Steven Stewart | last post by:
I have a user who has been using Excel for a while to keep statistics and print reports. She finds using it cumbersome because of long formulas and a lot of copying and pasting. I have designed...
2
by: Mustufa Baig | last post by:
Hi everybody, I have an ASP.NET website where clients can view their monthly billings by selecting different options. One of the option is the way they want to see the report i.e. whether they...
1
by: Mustufa Baig | last post by:
I have an ASP.NET website where I am showing off crystal reports to users by exporting them to pdf format. Following is the code: ---------------- 1 Private Sub ExportReport() 2 Dim oStream...
0
by: Grip | last post by:
Hi, I have gone throught the group and Microsoft's online help and have seen many suggestions but I am still seeking clarity: 1. I have an excel spreadsheet. Column A contains text that may...
4
by: somanyusernamesaretakenal | last post by:
What I am trying to achieve: Basically I have generated a report in access. This report needs to be updated using excel. (Updating the new data, not changing existing data) What I did was I...
3
by: yovation | last post by:
Hi, I have a 3 table database. 1 parent 1 child 1 child of child I would like to get the data into excel as 1 sheet (similar to a grouped report).
1
by: Sport Girl | last post by:
Hi everybody , i have the task of developing in Perl a script that retrieves data from 3 tables ( bugs, profiles, products) from a MySQL database called bugs and display them in an excel sheet...
6
by: Eddie | last post by:
Hi all, I am displaying a number of reports, and giving the users an option to display them on the web or download them to Excel. If they want the Excel file, I just use the PHP header command...
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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...

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.