当前位置:首页 > 网络编程 > WEB编程 > ASP.net > 解决CSV字段数据带有双引号的问题

解决CSV字段数据带有双引号的问题

点击次数:37 次 发布日期:2008-11-21 22:04:05 作者:源代码网
源代码网推荐

源代码网整理以下主要解决CSV字段数据带有双引号的问题

源代码网整理以下具体代码如下:

源代码网整理以下

以下为引用的内容:

源代码网整理以下        Public Function ChangeCsvSplitLine(ByVal strLine As String, ByVal iColNumber As Integer) As String()
        Dim strList() As String = strLine.Split(",")
        If strList.Length = iColNumber Then
        Return strList
        End If

源代码网整理以下        Dim i As Integer = 0
        Dim findSplitIndex As Integer = -1
        Dim index As Integer = 0
        Dim returnList(iColNumber) As String
        Dim strMerger As String = ""
        For i = 0 To strList.Length - 1
        If findSplitIndex = -1 Then
        If (strList(i)(0) = """" And strList(i)(strList(i).Length - 1) <> """") _
        Or (strList(i).Length = 1 And strList(i) = """") Then
        findSplitIndex = i
        Else
        returnList(index) = strList(i)
        index = index + 1
        End If
        Else
        If (strList(i)(0) <> """" And strList(i)(strList(i).Length - 1) = """") _
        Or (strList(i).Length = 1 And strList(i) = """") Then
        strMerger = ""
        For findSplitIndex = findSplitIndex To i
        strMerger = strMerger & strList(findSplitIndex) & ","
        Next
        strMerger = strMerger.Substring(0, strMerger.Length - 1)
        returnList(index) = strMerger
        index = index + 1
        findSplitIndex = -1
        End If
        End If
        Next
        Return returnList
        End Function

源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华