• VC操作Word之(二)


    大家都应该使用过Word提供的表格功能很是专业,如果在作一些数据库开发之类的软件对汇总的数据进行打印是常见的功能,这个如果用Word来实现个人感觉不错,废话少说说练咱就练。
    void CWordTestDlg::TestWord2()
    {
    _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(),6,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"));  
    app.SetVisible(TRUE);
    table.ReleaseDispatch();
    tables.ReleaseDispatch();
    sel.ReleaseDispatch();
    docs.ReleaseDispatch();
    saveDoc.ReleaseDispatch();
    app.ReleaseDispatch();
    }
     
  • 相关阅读:
    使用kubectl管理Kubernetes(k8s)集群:常用命令,查看负载,命名空间namespace管理
    HCIA学习笔记七:IP地址
    HCIA学习笔记四:华为设备登录信息
    HCIA学习笔记五:Telnet华为路由器
    HCIA学习笔记八:子网掩码划分
    HCIA学习笔记九:变长子网掩码VLSM
    HCIA学习笔记六:SSH华为路由器
    HCIA学习笔记三:华为VRP基本命令
    HCIA学习笔记二:eNSP的安装和使用
    vue3 学习初识体验常见指令vfor和vmodel
  • 原文地址:https://www.cnblogs.com/tyjsjl/p/2156096.html
Copyright © 2020-2023  润新知