0

This might be too much of a general question as I have yet to write code. I am just looking for some advice tips and tricks for how to go about my problem.

I am looking to create a UI using VB.Net which allows me to create a new column in an uploaded excel file and add specific data from a .DAT file to it.

There is only 1 sheet in the uploaded excel file. The info I want from the .DAT file is got by using data in a specific column in the excel file then finding the same data in the .DAT file and taking characters in position eg.123

If anybody knows if this is possible or the best way to go about coding it that would be great as I am open to learning new things and any help I can get :-)

Thanks

Protected Sub ReadDat(sender As Object, e As EventArgs)

    For Each lines As String In File.ReadLines(Server.MapPath("~/Files/test.dat"))

         If lines.Contains("xyz")  AndAlso lines.Substring(12, 3) Is "123" Then          
                
             MsgBox(lines)

         End If
     Next

 End Sub
  • 1
    Yes, is possible, I assume you know how to read the .DAT, for the excel, use some lib like NPOI (get it from nuget) – J.Salas Feb 24 '22 at 14:36
  • Yes I can read the DAT file using this code: Dim lines As String() = File.ReadAllLines(Server.MapPath("~/Files/test.dat")) However I am not sure how to pull out the lines that contain data in a specific excel data column – user11019667 Feb 24 '22 at 15:51
  • https://stackoverflow.com/questions/5855813/how-to-read-file-using-npoi <- to get the excel data. To be more specific about how to do the filtering we need to know the data structure in DAT and in excel files – J.Salas Feb 24 '22 at 15:56
  • @J.Salas Thank you for your reply I really appreciate it. I have added my code that reads the DAT file information I want. The excel file I am looking to import and edit has 1 sheet. The sheet name is the same as the excel file name. I want to add substrings of the data I have read from the DAT file to a new column in the excel file I have imported. I am using VB.NET. I have never used NPOI do you have any VB.NET examples or some sample code that might help me? – user11019667 Mar 02 '22 at 10:45

0 Answers0