求VC Excel编程API详解 需要包含单元格的背景颜色的设置、单元格的合并、单元格的字体设置、单元格的函数插入、图表操作相关API介绍。MFC,找了一天都没找到相关资料。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Msdn里面就有啊,你搜一下Office,programming,虽然是用Vba语言,但也可以嵌到你程序里的 先学会vba,然后根据vba移植成C++,多看excel自带的vba编程帮助文件 难道就没有现成的MFC 的API说明文档吗?不懂VB。 在Excel中生成表格的代码,参考一下吧 _Application app; COleVariant vTrue((short)TRUE), vFalse((short)FALSE); app.CreateDispatch(_T("Word.Application")); app.SetVisible(FALSE); //Create New Doc Documents docs=app.GetDocuments(); CComVariant tpl(_T("")),Visble,DocType(0),NewTemplate(false); docs.Add(&tpl,&NewTemplate,&DocType,&Visble); //Add Content:Text Selection sel=app.GetSelection(); sel.TypeText(_T("\t\t\t\t\t\t\t情况汇总\r\n")); sel.TypeText(_T("\t\t\t\t\t\t\t\t----------*******跨国公司\r\n")); COleDateTime dt=COleDateTime::GetCurrentTime(); CString strDT=dt.Format("%Y-%m-%d"); CString str("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"); str+=strDT; str+="\r\n"; sel.TypeText(str); //Add Table _Document saveDoc=app.GetActiveDocument(); Tables tables=saveDoc.GetTables(); CComVariant defaultBehavior(1),AutoFitBehavior(1); tables.Add(sel.GetRange(),7,11,&defaultBehavior,&AutoFitBehavior); Table table=tables.Item(1); sel.TypeText(_T("Test1")); sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0))); sel.TypeText(_T("Test2")); sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0))); sel.TypeText(_T("Test3")); sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0))); sel.TypeText(_T("Test4")); sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0))); sel.TypeText(_T("Test5")); sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0))); sel.TypeText(_T("Test6")); sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0))); sel.TypeText(_T("Test7")); sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0))); sel.TypeText(_T("Test8")); sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0))); sel.TypeText(_T("Test9")); sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0))); sel.TypeText(_T("Test10")); sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0))); sel.TypeText(_T("Test11")); for(int i=2;i<7;i+=2) { Cell c1=table.Cell(i,1); Cell c2=table.Cell(i+1,1); c1.Merge(c2); c1.ReleaseDispatch(); c2.ReleaseDispatch(); } app.SetVisible(TRUE); table.ReleaseDispatch(); tables.ReleaseDispatch(); sel.ReleaseDispatch(); docs.ReleaseDispatch(); saveDoc.ReleaseDispatch(); app.ReleaseDispatch(); app.SetVisible(TRUE); 第一次使用线程池,给位大牛指点下,谢谢 VB调用ocx 数据库大小问题 在directx中如何创建输入框? 请教: Raw Socket不在网卡混杂模式下能收到本机的tcp/udp数据吗? 知道局域网中服务器的IP地址,如何通过编程把一个文件上传到服务器中一个指定的文件夹中? 请问在VC++中怎么访问Excel中数据? 在自定义向导中如何跳到指定页(不连续页)? 如何学习MFC? 请问怎么做能在网页上运行的程序? vc 多线程同步 socket问题 求一个C++的http协议类
_Application app;
COleVariant vTrue((short)TRUE), vFalse((short)FALSE);
app.CreateDispatch(_T("Word.Application"));
app.SetVisible(FALSE);
//Create New Doc
Documents docs=app.GetDocuments();
CComVariant tpl(_T("")),Visble,DocType(0),NewTemplate(false);
docs.Add(&tpl,&NewTemplate,&DocType,&Visble);
//Add Content:Text
Selection sel=app.GetSelection();
sel.TypeText(_T("\t\t\t\t\t\t\t情况汇总\r\n"));
sel.TypeText(_T("\t\t\t\t\t\t\t\t----------*******跨国公司\r\n"));
COleDateTime dt=COleDateTime::GetCurrentTime();
CString strDT=dt.Format("%Y-%m-%d");
CString str("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
str+=strDT;
str+="\r\n";
sel.TypeText(str);
//Add Table
_Document saveDoc=app.GetActiveDocument();
Tables tables=saveDoc.GetTables();
CComVariant defaultBehavior(1),AutoFitBehavior(1);
tables.Add(sel.GetRange(),7,11,&defaultBehavior,&AutoFitBehavior);
Table table=tables.Item(1);
sel.TypeText(_T("Test1"));
sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0)));
sel.TypeText(_T("Test2"));
sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0)));
sel.TypeText(_T("Test3"));
sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0)));
sel.TypeText(_T("Test4"));
sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0)));
sel.TypeText(_T("Test5"));
sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0)));
sel.TypeText(_T("Test6"));
sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0)));
sel.TypeText(_T("Test7"));
sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0)));
sel.TypeText(_T("Test8"));
sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0)));
sel.TypeText(_T("Test9"));
sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0)));
sel.TypeText(_T("Test10"));
sel.MoveRight(COleVariant((short)1),COleVariant(short(1)),COleVariant(short(0)));
sel.TypeText(_T("Test11"));
for(int i=2;i<7;i+=2)
{
Cell c1=table.Cell(i,1);
Cell c2=table.Cell(i+1,1);
c1.Merge(c2);
c1.ReleaseDispatch();
c2.ReleaseDispatch();
}
app.SetVisible(TRUE);
table.ReleaseDispatch();
tables.ReleaseDispatch();
sel.ReleaseDispatch();
docs.ReleaseDispatch();
saveDoc.ReleaseDispatch();
app.ReleaseDispatch();
app.SetVisible(TRUE);