|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
如何把JSON数据转换成EXCEL格式的文档,便于财务人员做统计用,我自已尝试了几种方法,都无功而返,请各位过走路过的大侠们助我一臂之力,万分感谢!
JSON数据格式如下:
"search_result = [ {""sn"":""篮球"",""kz"":""birinxi"",""cp"":""baishi""} , {""sn"":""报龄"",""kz"":""kazet"",""py"":""baoling""} , {""sn"":""编简"",""kz"":""taryh"",""py"":""bianjian""} , {""sn"":""白兆灯"",""kz"":""tokا"",""py"":""biannianshi""} , {""sn"":""杠铃"",""kz"":""dop"",""py"":""bieshi""}];
//alert(1);
var str_html = ""<table>"";
if (search_result.length == 0 ) {
str_html = ""<tr><td>抱歉,暂时没有结果 / /td><td></td></tr>"";
} else {
for(var k in kz7_dict_search_result){
v = search_result[k];
str_html += ""<tr><td>""+v.sn+""</td><td>""+v.kz+""</td><td>""+v.py+""</td></tr>"";
}
}
str_html +=""<tr><td colspan='2'></td></tr></table>"";
document.getElementById(""search_result_div"").innerHTML = str_html;"
这么个结果,怎么将 sn、kz、cp后面的值写入到excel三个列中
我测试的代码是以下,可还是运行不成
Sub t()
Dim a, y As Object, s, json
a = Sheets("Sheet2").Range("A1").Value
Set json = CreateObject("MSScriptControl.ScriptControl")
json.Language = "JScript"
s = json.eval("var" & a & ";s='';for(x in a){ for(y in a[x]){s+=a[x][y]+'\t';}s+='\r'}")
Debug.Print s
End Sub
|
|