title: CSV to XLSX VB.NET
body: <p><a href="https://i.stack.imgur.com/WxfOw.png" rel="nofollow noreferrer">enter image description here</a><a href="https://i.stack.imgur.com/X6VTU.png" rel="nofollow noreferrer">enter image description here</a>I am just learning VB.NET and unfortunately I have been tasked with something I do not have a clue how to do. </p>
  
  <p>I need to create a quick windows based application to export csv files into an XLSX file. </p>
  
  <p>Yes, I know that other posts may have a similar topic however this one I believe is unique. </p>
  
  <p>The CSV file will have 5 headers, `Line, Component, Picked, Placed and Missed. We have part numbers in column 2 that would be placed under Component. I am understanding from the powers that be, this file sums the total part numbers i.e. 0-5490045 and the line JUKI 3 and totals Picked, Placed and Missed parts. I have provided a sample rows below. First row is the csv formatted, the second is the output. I am not sure which loop would be best a FOR loop, WHILE loop etc. I am assuming I will need a loop of some sort to get through all the data in the csv file.
  The only code I have opens the dialog box and allows for file selection and attempts to read into a datatable. I am attempting to get this working and then restructure some code.</p>
  
  <pre><code>Imports Spire.Xls
  Imports System.Windows.Forms
  Imports System.Data
  
  Public Class Form1
  
      Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  
          Dim dialog As OpenFileDialog = New OpenFileDialog
          dialog.Filter="CSV document(*.csv)|*.csv"
          Dim result As DialogResult = dialog.ShowDialog
          If(result=DialogResult.OK) Then
              Dim csvFile As String = dialog.FileName
              Dim workbook As Workbook = New Workbook
              workbook.LoadFromFile(csvFile,",")
              Dim worksheet As Worksheet = workbook.Worksheets(0)
              Dim dt As DataTable=worksheet.ExportDataTable
  
              Me.dataGridView1.DataSource=dt
          End If
      End Sub
  
  
  End Class
  
  
  
    JUKI 3    0-5490045 96    96  3
  
    Line  Component   Picked  Placed  Missed
    JUKI 3    0-5490045   99  96  3
  </code></pre>