Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2008 > Visual Basic 2008 Essentials
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #11 (permalink)  
Old June 1st, 2008, 03:51 AM
Authorized User
Points: 33, Level: 1
Points: 33, Level: 1 Points: 33, Level: 1 Points: 33, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2008
Location: , , .
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



Reply With Quote
  #12 (permalink)  
Old December 6th, 2013, 03:01 AM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 02:53 AM
vb.net and excel - HELP! vbnetgeek Pro VB.NET 2002/2003 3 May 10th, 2005 09:38 PM



All times are GMT -4. The time now is 06:05 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.