简体   繁体   English

Excel Power Query引用单元格

[英]Excel Power Query Referencing Cell

I am struggling to concatenate an API URL to include a function to take a value in a cell that I have named "testCell". 我正在努力将一个API URL连接起来,以包括一个函数,该函数在名为“ testCell”的单元格中采用一个值。 This API will pull details from the customer's tracking number. 该API将从客户的跟踪号中提取详细信息。 I just want this tracking number to be dynamic and reference a particular cell in Excel. 我只希望此跟踪号是动态的,并引用Excel中的特定单元格。 I have used an & ampersand but it clearly is not working. 我使用了&符,但显然无法正常工作。 The query works perfectly if I actually input an actual tracking number with the closing " (quotation marks) as well. 如果我实际上也以“”(引号)结尾输入了实际的跟踪号,则查询可以正常工作。

The Query is: 查询是:

let
    Source = Json.Document(Web.Contents("https://api.*****.com/api/track?tracking_number=" **&** Excel.Workbook(File.Contents(GetValue("testCell"))), [Headers=[#"Key1"="*****", #"Key2"=****"]])),
    #"Converted to Table" = Record.ToTable(Source),
    Value = #"Converted to Table"{0}[Value],
    #"Converted to Table1" = Record.ToTable(Value)

in

   #"Converted to Table1"

End of Query 查询结束

I've included a picture below also showing the error message 我在下面提供了一张图片,还显示了错误消息

Click here for image to the error 点击这里查看错误图片

I have also created a GetValue function of: 我还创建了一个GetValue函数:

 (rangeName) => 
    Excel.CurrentWorkbook(){[Name=rangeName]}[Content]{0}[Column1]

Can someone very kindly help? 有人可以帮忙吗?

The error is because you are trying use the string from your test cell to load an Excel file, which it doesn't sound like is what you are trying to do. 该错误是因为您正在尝试使用测试单元中的字符串来加载Excel文件,但这听起来不像您正在尝试执行的操作。 Remove the "Excel.Workbook(File.Contents())" and it should work fine. 删除“ Excel.Workbook(File.Contents())”,它应该可以正常工作。

let
    Source = Json.Document(Web.Contents("https://api.*****.com/api/track?tracking_number=" & GetValue("testCell"), [Headers=[#"Key1"="*****", #"Key2"=****"]])),
    #"Converted to Table" = Record.ToTable(Source),
    Value = #"Converted to Table"{0}[Value],
    #"Converted to Table1" = Record.ToTable(Value)

in

   #"Converted to Table1"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM