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

ASP.NET
web中缓存的使用
浅谈.net 中的职责链模式的使用
c# 连接字符串数据库服务器端口号
虚拟主机上用Asp.net实现Urlrewrite
ADO.NET Entity Framework存取数据库中图片
.Net基础:.Net开发人员必知的八个网站
.Net Micro Framework中的线程
详解.NET编程过程中的线程冲突
微软 ASP.NET 内置安全架构的完全解析
运行 ASP 时脚本超时问题最终解决办法
.Net应用:制作ASP脚本组件实现重启服务器
.NET 环境下使用C# 防止SQL注入式攻击
利用C#远程存取Access数据库
.Net中图片的快速处理
浅谈对程序开发中异常的理解和认识
C#中的Adapter设计模式浅析
C# 2010命名和可选参数的新特性
.Net基础:学习反射中的动态创建对象
微软 ASP.NET 环境下的页面验证控件
如何在 C# 中发起会议之类的特殊邮件

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 119 ::
收藏到网摘: 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