【发布时间】:2018-10-19 17:04:39
【问题描述】:
我正在尝试使用他们的 API 使用来自 Web 源的数据填充 Excel 工作簿。当我连接到数据源时,会出现高级查询编辑器并且我可以浏览数据,它的行为有点像 Access 数据库应用程序。当我选择“转换为表格”时,Excel 基本上将数据源的顶层放入 excel 工作簿中,我无法深入研究记录。这很难解释。
以下是 API 调用返回的内容(这是一条记录)
{"TotalResults":1,"ReturnedResults":1,"Results":[{"DueDate":"2018-10-31T00:00:00Z","FromDocument":"","AllowOnlinePayment":true ,"Paid":false,"Status":"Unpaid","Locked":false,"CustomerId":3148838,"CustomerName":"Cell C Limited","Customer":{"Name":"Cell C Limited ","SalesRepresentativeId":37307,"TaxReference":"4870194356","ContactName":"Charlene","Telephone":"0847770913","Fax":"","Mobile":"","Email": "csandstrom@cellc.co.za;accountspayable@cellc.co.za;EDC@cellc.co.za","WebAddress":"","Active":true,"IsObfuscated":false,"Balance":2333157.4800 "CreditLimit":0.0,"CommunicationMethod":2,"PostalAddress01":"Cell C","PostalAddress02":"Waterfall Campus","PostalAddress03":"C/O Maxwell Drive and Pretoria Road","PostalAddress04": "Buccleuch","PostalAddress05":"","DeliveryAddress01":"2018 年 9 月印刷和邮政分发","DeliveryAddress02":"","DeliveryAddress03":"","DeliveryAddress04":"","DeliveryAddress05":" PO: 待定","AutoAllocateToOldestInvoice":false,"EnableCustomerZone":false,"CustomerZoneGui d":"b9e1fbab-a23d-438c-b064-7a17d0a4dd56","CashSale":false,"TextField1":"","TextField2":"","TextField3":"","YesNoField1":false,"YesNoField2 ":false,"YesNoField3":false,"DefaultPriceListName":"默认价目表","AcceptsElectronicInvoices":false,"Modified":"2018-10-18T12:46:49.01","Created":"2018-10 -18T12:42:31.233","HasActivity":true,"ID":3148838},"SalesRepresentativeId":37307,"SalesRepresentative":{"ID":37307,"FirstName":"David","LastName": "Markman","Name":"David Markman","Active":true,"Email":"davidm@infoslipsconnect.com","Mobile":"","Telephone":"","Created":" 2018-10-18T12:42:31.233","修改":"2018-10-18T12:46:49.01"},"修改":"2018-10-18T12:46:49.01","创建":"2018 -10-18T12:42:31.233","ID":483959431,"Date":"2018-10-18T00:00:00Z","Inclusive":false,"DiscountPercentage":0.0,"TaxReference":"4870194356 ","DocumentNumber":"INV03357","Reference":"14480 - October Print & Post","Message":"新银行详细信息:\n账户名称: Infoslips Connect (Pty) Ltd\n银行: Investec Bank Limited\n分行: 100 Grayston Drive - 58 01 05\n帐号: 10011832402\n请将付款证明转发至 accounts@infoslipsconnect.com\n","Discount":0.0000,"Exclusive":98243.0400,"Tax":14736.4600,"Rounding" :0.0000,"Total":112979.5000,"AmountDue":112979.5000,"PostalAddress01":"Cell C","PostalAddress02":"Waterfall Campus","PostalAddress03":"C/O Maxwell Drive and Pretoria Road","PostalAddress04 ":"Buccleuch","PostalAddress05":"","DeliveryAddress01":"2018 年 9 月打印和邮政分发","DeliveryAddress02":"","DeliveryAddress03":"","DeliveryAddress04":"","DeliveryAddress05" :"PO: TBC","Printed":true,"Editable":true,"HasAttachments":false,"HasNotes":false,"HasAnticipatedDate":false,"Lines":[{"SelectionId":4804411," TaxTypeId":2691481,"ID":328907379,"Description":"CELL C PRINT & POST","LineType":0,"Quantity":1.0000,"UnitPriceExclusive":0.0000,"Unit":"","UnitPriceInclusive ":0.0000,"TaxPercentage":0.15,"DiscountPercentage":0.0,"Exclusive":0.0000,"Discount":0.0000,"Tax":0.0000,"Total":0.0000,"Comme nts":"","AnalysisCategoryId1":16041,"UnitCost":0.0000},{"SelectionId":12926677,"TaxTypeId":2691481,"ID":328907380,"Description":"CellC: PDF 编译"," LineType":0,"Quantity":52926.0000,"UnitPriceExclusive":0.3400,"Unit":"","UnitPriceInclusive":0.3900,"TaxPercentage":0.15,"DiscountPercentage":0.0,"Exclusive":17994.8400,"Discount ":0.0000,"Tax":2699.2300,"Total":20694.0700,"Comments":"","AnalysisCategoryId1":16041,"UnitCost":0.0000},{"SelectionId":12926854,"TaxTypeId":2691481," ID":328907382,"Description":"CellC: 舍入差","LineType":0,"Quantity":1.0000,"UnitPriceExclusive":-238.1600,"Unit":"","UnitPriceInclusive":-273.8800," TaxPercentage":0.15,"DiscountPercentage":0.0,"Exclusive":-238.1600,"Discount":0.0000,"Tax":-35.7200,"Total":-273.8800,"Comments":"","AnalysisCategoryId1":16041 ,"UnitCost":0.0000},{"SelectionId":12926687,"TaxTypeId":2691481,"ID":328907383,"Description":"CellC: PDF Print","LineType":0,"Quantity":109782.5000, "UnitPriceExclusive":0.7300,"Unit":"","UnitPriceInclu sive":0.8300,"TaxPercentage":0.15,"DiscountPercentage":0.0,"Exclusive":80141.2300,"Discount":0.0000,"Tax":12021.1800,"Total":92162.4100,"Comments":"","AnalysisCategoryId1 ":16041,"UnitCost":0.0000},{"SelectionId":12926854,"TaxTypeId":2691481,"ID":328907384,"Description":"CellC: 舍入差","LineType":0,"Quantity" :1.0000,"UnitPriceExclusive":-87.8200,"Unit":"","UnitPriceInclusive":-100.9900,"TaxPercentage":0.15,"DiscountPercentage":0.0,"Exclusive":-87.8200,"Discount":0.0000," Tax":-13.1700,"Total":-100.9900,"Comments":"","AnalysisCategoryId1":16041,"UnitCost":0.0000},{"SelectionId":12926687,"TaxTypeId":2691481,"ID": 328907385,"Description":"CellC: Hand Delivery","LineType":0,"Quantity":2.0000,"UnitPriceExclusive":0.3400,"Unit":"","UnitPriceInclusive":0.3900,"TaxPercentage":0.15, "DiscountPercentage":0.0,"Exclusive":0.6800,"Discount":0.0000,"Tax":0.1000,"Total":0.7800,"Comments":"","AnalysisCategoryId1":16041,"UnitCost":0.0000}, {"SelectionId":12926854,"TaxTypeId":2691481,"ID":328907 386,"Description":"CellC: 舍入差异","LineType":0,"Quantity":1.0000,"UnitPriceExclusive":-0.0100,"Unit":"","UnitPriceInclusive":-0.0100,"TaxPercentage": 0.15,"DiscountPercentage":0.0,"Exclusive":-0.0100,"Discount":0.0000,"Tax":0.0000,"Total":-0.0100,"Comments":"","AnalysisCategoryId1":16041,"UnitCost" :0.0000},{"SelectionId":12926761,"TaxTypeId":2691481,"ID":328907387,"Description":"CellC: Nixie","LineType":0,"Quantity":1.0000,"UnitPriceExclusive":432.2800 ,"Unit":"","UnitPriceInclusive":497.1200,"TaxPercentage":0.15,"DiscountPercentage":0.0,"Exclusive":432.2800,"Discount":0.0000,"Tax":64.8400,"Total":497.1200, "评论":"","AnalysisCategoryId1":16041,"UnitCost":0.0000}]}
我的问题是,我需要能够引用查询返回的数据,但不能这样做,因为一旦我转换为表格,数据似乎就不存在了。实现这一目标的最佳方法是什么?
截图如下:
谢谢, 史蒂文
【问题讨论】:
-
1) 可以分享一下这背后的M码吗(混淆个人信息)? 2) API 是否只返回一条记录?或者你只是分享一个作为例子? 3) 你对 VBA 解决方案持开放态度 4) 你想从表中得到什么数据?或者你只是想要整张桌子? 5) 您是否查看过 PowerQuery 用于处理 JSON 的功能? 6) API 是否公开且可测试?
-
您好。它背后没有我可以访问的代码。 API 由第 3 方提供。该调用一次返回 100 条记录。我对 VBA 持开放态度。
-
高级查询编辑器不显示M代码吗?
-
对不起,我对M代码不熟悉。然后我打开高级查询编辑器,它显示以下内容: let Source = Json.Document(Web.Contents("accounting.sageone.co.za/api/2.0.0/TaxInvoice/get?apikey={xxxxxxxxxxxxxxxxxxx}&companyid=12345&includeDetail=true&includeCustomerDetails=true&$orderby=Created%20desc")), Results = Source [结果],结果 1 = 结果 1 中的结果{0}
-
删除此 ^^ 评论,因为它包含您的 api 密钥。或者更确切地说,混淆 API 密钥。
标签: excel external-data-source