如何直接从JSON文件上传内容

时间:2016-11-10 14:59:01

标签: json excel excel-vba upload vba

我需要将文本文件中的数据上传到Excel。它是JSON数据。它大约50kB。如果我经常将其上传到单元格,Excel会冻结。有没有办法将文件的内容直接上传到VBA变量?

2 个答案:

答案 0 :(得分:1)

找到它,解决方案在这里,它的工作原理:

http://analystcave.com/

Dim fileName As String, textData As String, textRow As String, fileNo As Integer
fileName = "C:\text.txt"
fileNo = FreeFile 'Get first free file number  

Open fileName For Input As #fileNo
Do While Not EOF(fileNo)
   Line Input #fileNo, textRow
   textData = textData & textRow
Loop
Close #fileNo

答案 1 :(得分:0)

您不希望从文本导入Excel,而是从JSON导入Excel。 如果您必须在一段时间内完成一次,您最好使用一些免费的在线工具将JSON转换为CSV。例如this one。 否则,如果您要构建一个工具来将JSON文件解析为Excel,我建议您关注this tutorial

low-level kernel syscalls