Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
This is the code I have thus far. I can get it to read the first line and enter that into the existing excel spread sheet but it will not do more than that. Suggestions?

VB
If File.Exists(FileNameOnly) Then
                If FileNameOnly.Substring(FileNameOnly.IndexOf(".") + 1) = "txt" Then
                    Using sr As New StreamReader(File.Open(FileNameOnly, FileMode.Open))
                        Try

                            SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")

                            Dim ef As ExcelFile = ExcelFile.Load(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\Folder\RGP.xlsx")

                            Dim ws As ExcelWorksheet = ef.Worksheets(0)
                            ws.Cells("A2").Value = TextBox1.Text
                            ws.Cells("A3").Value = Label1.Text
                            ws.Cells("B2").Value = TextBox2.Text

                            Label5.Text = ws.Cells("E1").Value
                            Label6.Text = ws.Cells("E2").Value
                            Label7.Text = ws.Cells("E3").Value


                            Dim dt As DataTable = New DataTable
                            dt.Columns.Add("Test ID", Type.GetType("System.Int32"))

                            Do While sr.Peek() <> -1
                                dt.Rows.Add(sr.ReadLine)
                            Loop

                            Dim options = New InsertDataTableOptions()
                            options.ColumnHeaders = True
                            options.StartColumn = 1
                            options.StartRow = 4


                            ws.InsertDataTable(dt, options)


                            ef.Save(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\Folder\new22.xlsx")



                        Catch ex As Exception

                        End Try
                    End Using

                End If
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900