RE: Excel Reports in VB.NET
- From: "brix_zx2" <brixzx2@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 8 Apr 2005 07:19:02 -0700
You are trying to put data into a ***?? The way you got it looks like more
trouble than what you need. Or is it that you get data from this *** as
well? Here is a way to just put it into the ***.
'Sets up the Excel Interop
Dim NewForm27 As New Excel.Application
Dim W*** As Excel.Work***
'Opens the Form27 Excel document
NewForm27.Workbooks.Open("C:\Program
Files\97CS\SelfInspect\NewForm27.xls")
'Puts stuff into the form
WSheet = NewForm27.Workbooks.Item(1).Worksheets("Sheet1")
W***.Cells(2, 5) = txtCheckList.Text
W***.Cells(3, 2) = txtQuestion.Text
W***.Cells(5, 2) = cmbAnswer.Text
W***.Cells(2, 12) = txtNumber.Text
W***.Cells(2, 2) = txtDateInspected.Text
W***.Cells(6, 2) = txtComments.Text
W***.Cells(9, 2) = txtRootCause.Text
W***.Cells(11, 1) = txtRevDate1.Text
'Save and close excel ***.
W***.SaveAs("C:\Program Files\97CS\SelfInspect\Form27s\" &
txtCheckList.Text & ".xls")
NewForm27.Quit()
"krallabandi@xxxxxxxxx" wrote:
> Hi,
>
> I am trying to generate Excel *** 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 ***
> 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
>
>
.
- Follow-Ups:
- Re: Excel Reports in VB.NET
- From: krallabandi
- Re: Excel Reports in VB.NET
- From: krallabandi
- Re: Excel Reports in VB.NET
- References:
- Excel Reports in VB.NET
- From: krallabandi
- Excel Reports in VB.NET
- Prev by Date: Re: How to access aspx page thru the menu control only?
- Next by Date: Re: Reading Output from Shell Command
- Previous by thread: Excel Reports in VB.NET
- Next by thread: Re: Excel Reports in VB.NET
- Index(es):