请问如何把网站中的API数据整理到EXCEL表格中并进行计算?类似一下api
http://data.bter.com/api/1/ticker/btc_cny
谢谢!
怎么用EXCEL调用网站的API数据?
答案:2 悬赏:70
解决时间 2021-02-28 04:54
- 提问者网友:独菊痴梦
- 2021-02-27 22:42
最佳答案
- 二级知识专家网友:时光不老我们不分离
- 2021-02-28 00:05
这个返回的是JSON格式,要用JS翻译下再转入EXCEL中
全部回答
- 1楼网友:蜜罐小熊
- 2021-02-28 01:31
这是我以前写的一段程序,可以参考。 现在没有安装office,没法试了。
你在百度文库里找“使用mfc操作excel文件”就可以找到资料。
_application app; // app is an _application object.
workbooks books;
lpdispatch lpdisp; // often reused variable.
if(!app.createdispatch("excel.application"))
{
afxmessagebox("couldn't createdispatch() for excel");
return;
}
// set visible.
app.setvisible( false );
lpdisp = app.getworkbooks(); // get an idispatch pointer.
assert(lpdisp);
books.attachdispatch(lpdisp); // attach the idispatch pointer
colevariant
covtrue((short)true),
covfalse((short)false),
covoptional((long)disp_e_paramnotfound, vt_error);
// to open an existing workbook, you need to provide all
// 13 arguments for the open member function.
// the code below opens a workbook and adds it to the workbook's
// collection object.
// you need to modify the path and file name for your own
// workbook.
//
cstring strfile = filename;
lpdisp = books.open( strfile, // is a workbook.
covoptional, covoptional, covoptional, covoptional, covoptional,
covoptional, covoptional, covoptional, covoptional, covoptional,
covoptional, covoptional ); // return workbook's idispatch pointer.
assert(lpdisp);
book.attachdispatch( lpdisp );
// get the sheets collection and attach the idispatch pointer to your
// sheets object.
lpdisp = book.getsheets();
assert(lpdisp);
sheets.attachdispatch(lpdisp);
long nsheets = sheets.getcount();
char outfile[256];
for (long no = 1; no <= nsheets; no++)
{
lpdisp = sheets.getitem( colevariant((short)( no )) );
assert(lpdisp);
sheet.attachdispatch(lpdisp);
lpdisp = sheet.getusedrange();
assert(lpdisp);
range.attachdispatch(lpdisp);
variant ret = range.getvalue();
if ( ret.vt == vt_empty )
continue;
strcpy(outfile, filename);
char *p = strchr( outfile, '.' );
if ( p )
*p = 0;
cstring str = outfile;
str += "_";
str += sheet.getname();
if ( str.find( "说明" ) == -1 &&
str.find( "说明" ) == -1)
{
str_command[ 0 ].add( str );
int sign = -1;
ftalk->write( (const char*)&sign, 4 );
int n = str_command[ 0 ].getsize();
ftalk->write( (const char*)&n, 4 );
strcat(outfile, (lpcstr)sheet.getname());
strcat(outfile, ".cxx");
//std::ofstream ar(outfile);
std::ofstream ar;
//ar << (lpcstr)sheet.getname() << std::endl;
//create the safearray from the variant ret.
colesafearray sa(ret);
saveastalk( ar, sa );
}
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯