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

ASP.NET
利用ASP.NET和AJAX解决手工拼接HTML问题
Asp.net关于动态输出服务器控件的应用
技巧/诀窍:在ASP.NET中重写URL
ASP.NET 自定义控件从入门到精通3
以Post方式向网页发送数据
ASP.NET实现数据采集
使用ASP.NET Image Generation生成图片缩略图及水印
ASP.NET安全问题--ASP.NET安全架构
反思软件系统与软件系统之间的集成交互问题
.Net实现程序的插件机制
作为ASP.NET开发人员必须养成的编程习惯
总结了一下ADO.NET数据库连接的相关知识
VB.NET中有用的通用对象列表
HTTP Error 503与.NET 3.5 SP1 X64
ASP.NET创建Web服务之使用事务
ASP.NET中基类Page_Load方法后执行原因分析
ASP.NET中让网页弹出窗口不再困难
改变.net网站的默认解决方案位置
.net垃圾回收和CLR 4.0对垃圾回收所做的改进之二
.net垃圾回收和CLR 4.0对垃圾回收所做的改进之一

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


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