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

ASP.NET
ASP.NET编程中的十大技巧
ASP.NET常用函数(推荐)
ASP.NET上传图片并生成可带版权信息的缩略图
用javascript打造搜索工具栏
ASP.NET中动态控制RDLC报表
用ASP.NET还原与恢复Sql server
在ASP.NET里得到网站的域名
Asp.net中的mail的发送
用ASP.Net实现文件的在线压缩和解压缩
ASP.NET中文件上传下载方法集合
ASP.NET通过Remoting service上传文件
ASP.NET2.0服务器控件之Render方法
ASP.NET2.0新特性概述
asp.net2.0如何加密数据库联接字符串
用.NET 2.0压缩/解压功能处理大型数据
ASP.NET入门随想之检票的老太太
ASP与ASP.NET互通COOKIES的一点经验
ASP.NET2.0数据库入门之SqlDataSource
ASP.NET2.0数据库入门之SQL Server
ASP.NET 2.0下的条件编译

ASP.NET 中的 解决CSV字段数据带有双引号的问题


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 120 ::
收藏到网摘: n/a

主要解决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