VB.NET中CSV导入DATAGRID

转载 2006年05月19日 13:56:00

'=======IO.StreamReader直接读取CSV
        Dim intColCount As Integer = 0
        Dim blnFlag As Boolean = True
        Dim mydt As New DataTable

        Dim mydc As DataColumn
        Dim mydr As DataRow

        Dim strpath As String = "C:/ExportData.csv"
        Dim strline As String
        Dim aryline() As String

        Dim i As Integer
        Dim rowNum As Integer

        Dim mysr As System.IO.StreamReader = New System.IO.StreamReader(strpath, System.Text.Encoding.GetEncoding("GB2312"))
        strline = mysr.ReadLine()
        rowNum = 1
        While (strline <> Nothing)
            aryline = Split(strline, ",")
            If rowNum = 1 Then
                If (blnFlag = True) Then
                    blnFlag = False
                    intColCount = aryline.Length
                    For i = 0 To aryline.Length - 1
                        mydc = New DataColumn(aryline(i))
                        mydt.Columns.Add(mydc)
                    Next
                End If
            Else
                mydr = mydt.NewRow()
                For i = 0 To intColCount - 1
                    mydr(i) = aryline(i)
                Next
                mydt.Rows.Add(mydr)
            End If
            strline = mysr.ReadLine()
            rowNum = rowNum + 1
        End While
        ShowDemo.DataSource = mydt
        ShowDemo.DataBind()

相关文章推荐

读取CSV到DataGrid

Private Sub btnFileLoad_Click()Sub btnFileLoad_Click(ByVal sender As Object, ByVal e As System.Event...
  • regcy
  • regcy
  • 2009-03-05 22:28
  • 962

VB.NET DATAGRID或DATASET 输出CSV文件

Dim lstSelect As New LstConstrol        Dim DstTemp As DataSet        Dim strTem...
  • jk007
  • jk007
  • 2006-05-19 13:52
  • 2504

vb.net 写数据csv

Public Class Form2    Public Structure aa        Dim a As String      ...

VB.Net CSV文件处理类

Imports System.Data.OleDb Imports System.Data Imports System.Text Imports System.IO ''' ''' CSV文件读...

vb.net DataGrid Windows 控件执行分页

http://support.microsoft.com/kb/305271/zh-cn DataGrid Web 控件有内置的自动或自定义分页功能,但是 DataGrid Wind...

VB.net中DataGrid导出为Excel文件函数

Public Function ExportXLsD(ByVal datagrid As DataGrid) ', ByVal Title As String) 'Dim Mytab...

.NET 导入CSV 或 Excel

  • 2014-06-28 15:20
  • 36KB
  • 下载

asp.net 导入 CSV 文件

VB.NET DataGridView中的数据导入到Excel

背景介绍:数据库里"卡信息表"中数据已成功在DataGridView1控件中显示,实现代码请见博客《VB.NET 中DataGridView显示数据库中的数据》,瑕疵颇多,望高人指教;这里只介绍D...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)