Pa, ne znam koliko ce ti ovo biti sada od pomoci, jer proslo je dosta vremena...
Dodaj referencu na excel:Project/Add Reference/COM/Microsoft Excel Object Library
Potom da bi punio i otvarao excel file postavi jeden TextBox i jedno dugme Button. Mozes da otvoris postojeci file sa odredjenim proracunima i formulama ili da ga punis... Ako otvaras postojeci ide ovako:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xlapp As Excel.Application
Dim xlwrk As Excel.Workbook
Dim xlsht As Excel.Worksheet
xlapp = New Excel.Application
xlwrk = xlapp.Workbooks.Open("E:\Documents and Settings\Administrator\Desktop\Book11.xls") 'otvara postojeci file
xlsht = xlwrk.Worksheets(1) 'otvara sheet 1 a ti mozes da biras koji
xlsht.Cells(1, 1) = TextBox1.Text 'celija koju puni
xlwrk.SaveAs("C:\Baza.xls")
'ako hoces da to cuvas pod odredjenim imenom na odredjenom mestu, a da ti onaj book koji si otvorio ostane blanko za novi unos onda ide gore navedeni red, a ako snimas izmene u file koji si otvorio, onda:
xlwrk.Save()
xlwrk.Close()
xlsht = Nothing
xlwrk = Nothing
xlapp = Nothing
End Sub
End Class
a ako nemas vec ga kreiras, onda:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xlapp As Excel.Application
Dim xlwrk As Excel.Workbook
Dim xlsht As Excel.Worksheet
Set xlapp = New Excel.Application
Set xlwrk = xlapp.Workbooks.Add
Set xlsht = xlwrk.Worksheets(1)
xlsht.Cells(red, 1) = Text1.Text
xlsht.Cells(red, 2) = Text2.Text
xlwrk.SaveAs "C:\proba.xls" 'ime fajla koji hoces da kreiras
xlwrk.Close
Set xlsht = Nothing
Set xlwrk = Nothing
Set xlapp = Nothing
End Sub
End Class
Trenutno radim na tome da napravim da kada kliknes na to dugme, on puni prvu praznu celiju u datom book-u, i da ti ocisti textBox za novi unos...
Kada uradiom, ako uradim :-?, i to cu postaviti...
Ako neko od vas vec zna kako bi to moglo, bila bih jako zahvalna ako bi to postavili.
Pozdrav!
snoop.edit
|