Oisko mitää ohjeita tai neuvoja minkä avulla voisin tehdä yhteyden vb.netin ja execelin välille?? Tekemäni ohjelma on eräänlainen tilastointi ohjelma josta tarttis saadaa ohjelmassa olevat muuttujat siirrettyä suoraan exceliin!!Voisiko joku hiukkasen auttaa?
Googleta tämä:
Knowledge Base - 301982
Siis näin:
Lisää referenssi: Project/Add reference/ välilehti COM
Etsi Microsoft Excel Object Library / Select/ OK
Tässä esimerkkikoodi VB.net-helpistä:
Dim oXL As Excel.Application Dim oWB As Excel.Workbook Dim oSheet As Excel.Worksheet Dim oRng As Excel.Range ' Start Excel and get Application object. oXL = CreateObject("Excel.Application") oXL.Visible = True ' Get a new workbook. oWB = oXL.Workbooks.Add oSheet = oWB.ActiveSheet ' Add table headers going cell by cell. oSheet.Cells(1, 1).Value = "First Name" oSheet.Cells(1, 2).Value = "Last Name" oSheet.Cells(1, 3).Value = "Full Name" oSheet.Cells(1, 4).Value = "Salary" '..... ' Fill A2:B6 with an array of values (First and Last Names). oSheet.Range("A2", "B6").Value = saNames ' Fill C2:C6 with a relative formula (=A2 & " " & B2). oRng = oSheet.Range("C2", "C6") oRng.Formula = "=A2 & "" "" & B2" ' Fill D2:D6 with a formula(=RAND()*100000) and apply format. oRng = oSheet.Range("D2", "D6") oRng.Formula = "=RAND()*100000" oRng.NumberFormat = "$0.00" ' AutoFit columns A:D. oRng = oSheet.Range("A1", "D1") oRng.EntireColumn.AutoFit() ' Manipulate a variable number of columns for Quarterly Sales Data. Call DisplayQuarterlySales(oSheet) ' Make sure Excel is visible and give the user control ' of Excel's lifetime. oXL.Visible = True oXL.UserControl = True ' Make sure that you release object references. oRng = Nothing oSheet = Nothing oWB = Nothing oXL.Quit() oXL = Nothing
Aihe on jo aika vanha, joten et voi enää vastata siihen.