hi all
i am trying to read and write data in Excel file from asp.net
I am able to read the data of particular cell, but i am not able to write in Excel file.
I am getting error: ComException: Document not saved;
Any help would be appreciated.
thanx.
*************** *************** ***********My Code*********** *************** *********
Dim MyExcel As Microsoft.Offic e.Interop.Excel .Application
Dim MyWorkbook As Microsoft.Offic e.Interop.Excel .Workbook
Dim MySheet As Microsoft.Offic e.Interop.Excel .Worksheet
Dim MyCell As Microsoft.Offic e.Interop.Excel .Range
MyExcel = New Microsoft.Offic e.Interop.Excel .Application
MyExcel.Workboo ks.Open("C:\Ine tpub\wwwroot\Ad dNewPromotion\E xcel1.xls", , False)
MyWorkbook = MyExcel.Applica tion.ActiveWork book
MySheet = MyWorkbook.Acti veSheet
Label1.Text() = MySheet.Cells.I tem(1, 1).value
MySheet.Cells.I tem(2, 2).value = "Example"
MyExcel.ActiveW orkbook.SaveAs( "C:\Inetpub\www root\AddNewProm otion\Excel2.xl s")
MyExcel.ActiveW orkbook.Close()
MyExcel = Nothing
MyWorkbook = Nothing
MySheet = Nothing
*************** *************** ************End *************** *************** *******
i am trying to read and write data in Excel file from asp.net
I am able to read the data of particular cell, but i am not able to write in Excel file.
I am getting error: ComException: Document not saved;
Any help would be appreciated.
thanx.
*************** *************** ***********My Code*********** *************** *********
Dim MyExcel As Microsoft.Offic e.Interop.Excel .Application
Dim MyWorkbook As Microsoft.Offic e.Interop.Excel .Workbook
Dim MySheet As Microsoft.Offic e.Interop.Excel .Worksheet
Dim MyCell As Microsoft.Offic e.Interop.Excel .Range
MyExcel = New Microsoft.Offic e.Interop.Excel .Application
MyExcel.Workboo ks.Open("C:\Ine tpub\wwwroot\Ad dNewPromotion\E xcel1.xls", , False)
MyWorkbook = MyExcel.Applica tion.ActiveWork book
MySheet = MyWorkbook.Acti veSheet
Label1.Text() = MySheet.Cells.I tem(1, 1).value
MySheet.Cells.I tem(2, 2).value = "Example"
MyExcel.ActiveW orkbook.SaveAs( "C:\Inetpub\www root\AddNewProm otion\Excel2.xl s")
MyExcel.ActiveW orkbook.Close()
MyExcel = Nothing
MyWorkbook = Nothing
MySheet = Nothing
*************** *************** ************End *************** *************** *******