Wrox Programmer Forums
|
Visual Basic 2008 Essentials If you are new to Visual Basic programming with version 2008, this is the place to start your questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2008 Essentials section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 1st, 2008, 03:51 AM
Authorized User
 
Join Date: Jun 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

try this

        xlApp = New Excel.ApplicationClass
        xlWorkBook = xlApp.Workbooks.Add(misValue)
        xlWorkSheet = xlWorkBook.Sheets("sheet1")
        xlWorkSheet.Cells(1, 1) = "http://vb.net-informations.com"
        xlWorkSheet.SaveAs("C:\vbexcel.xlsx")

you can find the full source code here :

http://vb.net-informations.com/excel...reate_file.htm



 
Old December 6th, 2013, 04:01 AM
Registered User
 
Join Date: Nov 2013
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Working with Excel in VB.NET

Hi, if your "first open cell" refers to a first available cell then you can try the following sample:

Code:
Public Class Form1

Dim oEx As ExcelFile

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
	oEx = ExcelFile.Load("C:\Program Files\Nexulator\Schedule.xls")
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
	Dim sheetEx As ExcelWorksheet = oEx.Worksheets.ActiveWorksheet
	For Each cell As ExcelCell In sheetEx.Columns("A").Cells
		If cell.Value Is Nothing Then
			cell.Value = "TextBox1.Text"
			Exit For
		End If
	Next
	oEx.Save("C:\Program Files\Nexulator\Schedule.xls")
End Sub

End Class
I used this VB.NET Excel component because personally I found it easier then excel automation, I believe you will find it very easy to use too. Also if your open cell refers to a Selected cell then you can use a sheetEx.ViewOptions.SelectedCells to get or set the current workbooks selected cell and its value.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Working With Word Template From ASP.NET and VB.NE Haribabu74 Classic ASP Components 2 July 22nd, 2014 05:11 PM
Excel reports in vb.net juster21 .NET Framework 2.0 1 March 3rd, 2014 03:53 AM
vb.net and excel - HELP! vbnetgeek Pro VB.NET 2002/2003 3 May 10th, 2005 09:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.