Sreekumar P
Sreekumar P

Reputation: 6050

import statement for excel in windows application

I am exporting the contents of one excel file data to the other excel file by using the range excel object in a windows application.. while declaring the object, am getting the error like type excel object is not declared.. here is my code.

  Dim excelApp As excelobject
  'string filePath = "D:\Test.xls"
  excelApp = New Excel.Application()
  excelWorkBook = excelApp.Workbooks.Open(epath)
     excelWorkSheet = (Excel.Worksheet)excelWorkBook.Worksheets.get_Item(1)
  excelWorkSheet.Copy(Type.Missing, Type.Missing)
     excelWorkSheet = excelApp.Workbooks[2].Sheets[1]




 if (excelWorkBook != null)

    excelWorkBook.Close()
  End If

   if (excelApp != null)

    excelWorkBook = excelApp.Workbooks.Open("D:\Test-1.xls")
    excelApp.Quit()

    this.releaseObject(excelWorkSheet)
    this.releaseObject(excelWorkBook)
    this.releaseObject(excelApp)


  End If

Upvotes: 0

Views: 894

Answers (1)

Edwin de Koning
Edwin de Koning

Reputation: 14387

You mean this?

Imports Microsoft.Office.Interop.Excel

Upvotes: 1

Related Questions