yuanweisen

 

Excel文件转成xml文件流

'Excel数据转成Xml文件流
Function getSheetXml()
 Dim sXml
    Dim i
    Dim sXmlRow
    Dim ProductGroup
    '头文件流
    sXml = "<root><version><t>" & ReportName & "</t>"
    '遍历Excel每个数据,转为Xml文件流
    For i = MinRow To RetMaxRow - 1
        sXmlRow = ""
        sXmlRow = "<record>" & _
                     "<RowIndex>" & XmlEncode(i) & "</RowIndex>" & _
                     "<Quarter>" & XmlEncode(Trim(Cells(i, 1))) & "</Quarter>" & _
                     "<WeekNo>" & XmlEncode(Trim(Cells(i, 2))) & "</WeekNo>" & _
                     "<BPCode>" & XmlEncode(Trim(Cells(i, 3))) & "</BPCode>" & _
                     "<BPType>" & XmlEncode(Trim(Cells(i, 4))) & "</BPType>" & _
                     "<BusinessUnit>" & XmlEncode(Trim(Cells(i, 5))) & "</BusinessUnit>" & _
                     "<Product/Metric>" & XmlEncode(Trim(Cells(i, 6))) & "</Product/Metric>" & _
                     "<Finalised Rebate>" & XmlEncode(Trim(Cells(i, 7))) & "</Finalised Rebate>" & _
                  "</record>"

        sXml = sXml & sXmlRow
    Next
    '返回xml文件流
    getSheetXml = sXml & "</root>"
End Function

posted on 2009-01-06 17:07    阅读(628)  评论(0编辑  收藏  举报

导航