Thursday, April 16, 2009

Drivers Education In Suffolk County



this code is for information sacral eentro an Excel arcgivo



'------------------------- ----------------------------------------------
'This file is part of the Microsoft. NET Framework SDK Code Samples.
'
' Copyright (C) Microsoft Corporation. All rights reserved.
'
' This source code is Intended only as a supplement to Microsoft
'Development Tools and / or on-line documentation. See These Other
'materials for Detailed Information Regarding Microsoft code samples.
'
' THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
'KIND, EITHER IMPLIED OR EXPRESSE, Including BUT NOT LIMITED TO THE
' Warranties IMPLIED OF MERCHANTABILITY AND / OR FITNESS FOR A
'PARTICULAR PURPOSE.

adding the reference''Microsoft ActiveX Data Objects 2.8 Library''
like to excel files
'------------------------- ----------------------------------------------
option strict off

Imports System Imports System.Reflection 'For Missing.Value and
BindingFlags Imports System.Runtime.InteropServices' For COMException Imports Microsoft.Office.Interop.Excel


AutoExcel

Class Dim app As Application
Public Sub Main (ByVal ds As DataSet)

Console.WriteLine("Creating new Excel Application")

app = New Application()
If app Is Nothing Then
Console.WriteLine("ERROR: EXCEL couldn't be started!")
Environment.ExitCode = 0
Exit Sub
End If

Console.WriteLine("Making application visible")
app.Visible = True

Console.WriteLine("Getting the workbooks collection")
Dim workbooks As Workbooks
workbooks = app.Workbooks

Console.WriteLine("Adding a new workbook")
Dim workbook As _Workbook
workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet)

Console.WriteLine("Getting the worksheets collection")
Dim sheets As Sheets
sheets = workbook.Worksheets

Dim worksheet As _Worksheet
worksheet = sheets.Item(1)
If worksheet Is Nothing Then
Console.WriteLine("ERROR: worksheet == null")
End If


End Sub
Public Sub carga(ByVal rss As ADODB.Recordset)
app.Application.Range("A9").CopyFromRecordset(rss)
app.ActiveSheet.Columns("A:zz").Select()
app.ActiveSheet.Range("A1193").Activate()
app.ActiveSheet.Columns ("A: ZZ"). EntireColumn.AutoFit ()
app.ActiveSheet.Range ("A1: P1.") Select () End Sub




end class also can be found on : http://cid-70ba4130e4a6a153.skydrive.live.com/browse.aspx/.Public/record% 20set% 20 +% 20excel

0 comments:

Post a Comment