以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 请问如何读取这个文件里的数据呢? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=161424) |
||||
-- 作者:hongye -- 发布时间:2021/3/17 9:46:00 -- 请问如何读取这个文件里的数据呢?
请问如何提取这个文件里全部的 作废日期,发票号码, 客户识别号,税额,发票状态,发票代码,原发票号码,价税合计,客户名称,开票日期,合计金额,作废人,一条信息一行
|
||||
-- 作者:有点蓝 -- 发布时间:2021/3/17 9:51:00 -- 参考:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=161169&skin=0 |
||||
-- 作者:hongye -- 发布时间:2021/3/17 10:34:00 -- 不理解,主要是这个文件里是双引号,不知道怎么写代码 |
||||
-- 作者:有点蓝 -- 发布时间:2021/3/17 11:11:00 -- Dim xml As String = FileSys.ReadAllText("D:\\问题\\已开发票增值税发票导出_20210316190645.xml",Encoding.Default) Dim xo As Foxtable.XObject = Foxtable.XObject.Parse(xml) Output.Show(xo.Tostring) \'属性使用@+名称表示,看完整json就明白了 Output.Show(xo("@INFO")) Dim bms As JArray = xo("YKFP")("Row") Output.Show(cstr(bms(0)("@主要商品名称")) & "=" & cstr(bms(0)("@合计金额"))) |
||||
-- 作者:hongye -- 发布时间:2021/3/17 11:38:00 -- Dim dlg As new OpenFileDialog If dlg.ShowDialog = DialogResult.OK Then Dim txt As String = FileSys.ReadAllText(dlg.FileName, Encoding.Default) Dim idx1 As Integer = txt.IndexOf("<YKFP>") Dim idx2 As Integer = txt.IndexOf("</YKFP>") Dim xmlDoc As New System.XML.XmlDocument xmlDoc.Loadxml(txt.Trim) Dim ndList = xmlDoc.GetElementsByTagName("Row") For Each dr As object In ndlist Dim ndr As DataRow = DataTables("表A").find("第一列 = \'" & dr("发票代码").innertext & "\'And 第二列 = \'" & dr("发票号码").innertext & "\'") If ndr Is Nothing Then ndr = DataTables("表A").addnew For Each n As System.XML.XmlNode In dr.childNodes output.show(n.Name & " = " & n.InnerText) If n.name = "发票代码" Then ndr("第一列") = n.innertext End If If n.name = "发票号码" Then ndr("第二列") = n.innertext End If If n.name = "客户识别号" Then ndr("第三列") = n.innertext End If If n.name = "开票日期" Then Dim str = n.innertext ndr("第四列") = str.SubString(0,4) + "-" + str.SubString(4,2) + "-" + str.SubString(6,2) End If If n.name = "合计金额" Then ndr("第五列") = n.innertext End If If n.name = "税额" Then ndr("第六列") = n.innertext End If If n.name = "发票状态" Then ndr("第七列") = n.innertext End If Next Next End If 帮我看看这个代码错哪了?
|
||||
-- 作者:有点蓝 -- 发布时间:2021/3/17 12:01:00 -- https://blog.csdn.net/qq_40868987/article/details/94575707 |
||||
-- 作者:hongye -- 发布时间:2021/3/17 12:41:00 -- 能不能帮我改改,你发的链接看不懂 |
||||
-- 作者:有点蓝 -- 发布时间:2021/3/17 13:35:00 -- 暂时没有时间去研究这些用法,要使用请自行研究。 或者看4楼的用法和帮助:http://www.foxtable.com/mobilehelp/topics/0171.htm
|
||||
-- 作者:hongye -- 发布时间:2021/3/17 17:28:00 -- Dim dlg As new OpenFileDialog If dlg.ShowDialog = DialogResult.OK Then Dim txt As String = FileSys.ReadAllText(dlg.FileName, Encoding.Default) Dim idx1 As Integer = txt.IndexOf("<YKFP>") Dim idx2 As Integer = txt.IndexOf("</YKFP>") Dim xmlDoc As New System.XML.XmlDocument xmlDoc.Loadxml(txt.Trim) Dim ndList = xmlDoc.GetElementsByTagName("Row") For Each dr As object In ndlist Dim ndr As DataRow = DataTables("表A").find("第一列 = \'" & dr.Attributes("发票号码").value & "\'And 第二列 = \'" & dr.Attributes("发票号码").value & "\'") If ndr Is Nothing Then ndr = DataTables("表A").addnew ndr("第一列") = dr.Attributes("发票代码").value ndr("第二列") = dr.Attributes("发票号码").value ndr("第三列") = dr.Attributes("客户识别号").value \'Dim str = dr.Attributes("开票日期").value \'ndr("第四列") = str.SubString(0,4) + "-" + str.SubString(4,2) + "-" + str.SubString(6,2) ndr("第四列") = dr.Attributes("开票日期").value ndr("第五列") = dr.Attributes("合计金额").value ndr("第六列") = dr.Attributes("税额").value ndr("第七列") = dr.Attributes("发票状态").value Next End If 这样写代码可以导入数据了,但是怎么解决它的重复导入呢?
|
||||
-- 作者:有点蓝 -- 发布时间:2021/3/17 17:41:00 -- 上面红色代码就是限制重复导入的呀,找不到才新增。 |