Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete spreadsheet thru vb.net help

Status
Not open for further replies.

Hueby

MIS
Joined
Oct 20, 2004
Messages
321
Location
US
Hi all,

I need to delete all rows in a excel spreedsheet, except for row 1, and do it automatically in vb.net with some code.

Basically, the user enters some data in the sheet, I have it insert into a sql DB, then I want to go ahead and delete the values in the excel sheet for them.

Can anyone point me in the right direction?

- Matt
 
I just happened to be working with Excel from .Net today. Anyways, first you'll want to add a COM reference to the project for excel. I think it's under Microsoft.Office.Excel on the COM tab of the references.

I have code at work, but I can't remember much off the top of my head. Once you have the reference add "Imports Microsoft.Office.Interop" to the top of your class. Then you can create an application (dim exApp as New Excel.Application). Then use the application's open method to load a work book (something like: dim exWB as Excel.WorkBook = exApp.Open("FileName") )

Once you have a workbook object you can grab the active work sheet, grab a range, and I wouldn't be suprized if Range.EntireRow had a .Delete method.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top