|
这是导出.xml文件的代码实例。在access中导出可以在税务软件(金税3)导入的xml文件。有需要的可以参考。
Dim j, i, k, n, m, q, p As Integer
Dim Aw, Nm, Zs, Dn, spb As String
Nm = Me.List0.Column(1, 1)
Zs = Me.List0.Column(0, 1)
m = 0
myfile = path & "\金税\" & Format(Date, "YYYY-MM-DD") & Nm & "-" & Zs & "-金税2.0导入.xml"
If Dir(myfile) <> "" Then Kill myfile
Open myfile For Append As #1
Print #1, "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "GBK" & Chr(34) & " ?>" '<?xml version="1.0" encoding="GBK" ?>
Print #1, "<Kp>"
Print #1, "<Version>2.0</Version>" '//有此节点,则表示用带分类编码
Print #1, " <Fpxx>"
Print #1, " <Zsl>" & Trim(Text14) & "</Zsl>" '//此文件含有的单据信息数量,(文件中含有多少份发票<=500)
Print #1, " <Fpsj>"
'For j = 1 To k
Print #1, " <Fp>"
Print #1, " <Djh>" & Trim(Text14) & "</Djh>" '//单据号(20字节)
Print #1, " <Gfmc>"; "</Gfmc>" '//购方名称(100字节)
Print #1, " <Gfsh>"; "</Gfsh>" '//购方税号
Print #1, " <Gfyhzh>"; "</Gfyhzh>" '//购方银行账号(100字节)
Print #1, " <Gfdzdh>"; "</Gfdzdh>" '//购方地址电话(100字节)
Print #1, " <Bz>"; "</Bz>" '//备注(240字节)
Print #1, " <Fhr>"; "</Fhr>" '//复核人(8字节)
Print #1, " <Skr>" & "</Skr>" '//收款人(8字节)
Print #1, " <Spbmbbh>1.0</Spbmbbh>"
Print #1, " <Hsbz>0</Hsbz>"
Print #1, " <Spxx>"
For i = 1 To Me.List1.ListCount - 1
m = m + 1
Print #1, " <Sph>"
Print #1, " <Xh>" & Format(Trim(Text14), "#####") & "</Xh>" '//序号
Print #1, " <Spmc>" & Trim(List1.Column(3, i)) & "</Spmc>" '//商品名称,金额为负数时此项为折扣行数(100字节)
Print #1, " <Ggxh>" & Trim(List1.Column(4, i)) & "</Ggxh>" '//规格型号(40字节)
Select Case Trim(List1.Column(12, i))
Case "1"
spb = "1070302120000000000" '片剂
Case "3"
spb = "1070304010000000000" '片剂
Case "2"
spb = "1070302050000000000" '片剂
Case "4"
spb = "1070302140000000000" '片剂
Case "5"
spb = "1070302070000000000" '片剂
Case "6"
spb = "1070302060000000000" '胶囊剂
Case "8"
spb = "1070304990000000000" '片剂
Case "9"
spb = "1070302030000000000" '注射剂
Case "10"
spb = "1070308010000000000" '片剂
Case "11"
spb = "1070302130000000000" '片剂
Case "12"
spb = "1070304060000000000" '片剂
Case "13"
spb = "1070302130000000000" '片剂
Case "14"
spb = "1070302090000000000" '片剂
Case "15"
spb = "1070302120000000000" '片剂
Case "16"
spb = "1070302130000000000" '片剂
Case "17"
spb = "1070304990000000000" '片剂
Case "18"
spb = "1070304060000000000" '片剂
Case "19"
spb = "1070304060000000000" '片剂
Case "20"
spb = "1070302140000000000" '片剂
Case "21"
spb = "1070302140000000000" '片剂
Case "22"
spb = "1070302100000000000" '片剂
Case "23"
spb = "1070302100000000000" '片剂
Case "24"
spb = "1070302070000000000" '片剂
Case "25"
spb = "1070304990000000000" '片剂
Case "26"
spb = "1070302130000000000" '片剂
Case "27"
spb = "1070302100000000000" '颗粒剂
Case "28"
spb = "1070302130000000000" '片剂
Case "29"
spb = "1070302130000000000" '片剂
Case "30"
spb = "1070302090000000000" '片剂
Case "31"
spb = "1070304010000000000" '片剂
Case "32"
spb = "1070302060000000000" '片剂
Case "33"
spb = "1070302070000000000" '片剂
Case "34"
spb = "1070304990000000000" '片剂
Case "35"
spb = "1070303010000000000" '片剂
Case "36"
spb = "1070304990000000000" '片剂
Case "37"
spb = "1070302140000000000" '片剂
Case Else
spb = "1070302140000000000" '颗粒剂
End Select
Print #1, " <Jldw>" & Trim(List1.Column(5, i)) & "</Jldw>" '//计量单位(32字节)
Print #1, " <Spbm>" & spb & "</Spbm>" '//Spbm(32字节)
Print #1, " <Qyspbm>"; "</Qyspbm>"
Print #1, " <Syyhzcbz>0</Syyhzcbz>"
Print #1, " <Lslbz>"; "</Lslbz>" '//零税率标识 空:非零税率,0:出口退税,1:免税,2:不征收,3普通零税率( 1字节)"
Print #1, " <Yhzcsm>"; "</Yhzcsm>"
Print #1, " <Dj>" & Format(Trim(List1.Column(8, i)), "0.##############") & "</Dj> " '//单价(不含税单价)
Print #1, " <Sl>" & Format(Trim(List1.Column(6, i)), "0.######") & "</Sl>" '//数量
Print #1, " <Je>" & Format(Trim(List1.Column(9, i)), "0.######") & "</Je>" '//金额【金额=Round(不含税金额,2)】,当金额为负数时为折扣行
Print #1, " <Slv>" & Format(Text11, "0.######") & "</Slv>" '//税率,税金=ROUND(ROUND(不含税金额,2)*税率,2)
Print #1, " <Kce>"; "</Kce>" '//扣除额,用于差额税计算"
Print #1, " </Sph>"
Next i
Print #1, " </Spxx>"
Print #1, " </Fp>"
'Next j
Print #1, " </Fpsj>"
Print #1, " </Fpxx>"
Print #1, "</Kp>"
Close #1
MsgBox "完成导出,您可以在桌面金税文件夹中找到该文件导入金税2.0!", , "提示" |
|