zoukankan      html  css  js  c++  java
  • qt 操作word

    //修改doc

     QString filepath="e:\aa.doc";
    
     QAxWidget *word = new QAxWidget("Word.Application");
    
     QAxObject *document =word->querySubObject("Documents");
    
     document->dynamicCall("Open(const QString&)",QString(filepath));
    
     QAxObject *doc = word->querySubObject("ActiveDocument");//获取当前工作簿
    
     QAxObject *table=doc->querySubObject("Tables(int)",1);
    
     QAxObject *cell=table->querySubObject("Cell(int,int)",1,1);
    
     cell->querySubObject("Range")->setProperty("Text","111");
    
     //doc->dynamicCall("Tables(1).Cell(1, 1).Range.Text='111'");
    
     doc->dynamicCall("Save()");
    
     document->dynamicCall("Close()");//关闭工作簿
    
     qDebug() << QString(QDir::toNativeSeparators(filepath));
    
     word->dynamicCall("Quit()");//关闭excel
    
     qDebug() << document;
    
     doc =NULL;
    
     document=NULL;
    
     word=NULL;
    
     qDebug() << QString(QDir::toNativeSeparators(filepath));
    
     //新增doc
    
     /**
    
     QString filepath="e:\aa.doc";
    
     QAxWidget *word = new QAxWidget("Word.Application");
    
     //word->setControl("Word.Application");//连接word控件
    
     QAxObject *document =word->querySubObject("Documents");
    
     qDebug() << document;
    
     document->dynamicCall("Add()");
    
     QAxObject *doc = word->querySubObject("ActiveDocument");//获取当前工作簿
    
     doc->dynamicCall("SaveAs(const QString&)",QString(QDir::toNativeSeparators(filepath)));//保存至filepath,注意一定要用QDir::toNativeSeparators将路径中的"/"转换为"",不然一定保存不了。
    
     document->dynamicCall("Close()");//关闭工作簿
    
     qDebug() << QString(QDir::toNativeSeparators(filepath));
    
     word->dynamicCall("Quit()");//关闭excel
    
     qDebug() << document;
    
     doc =NULL;
    
     document=NULL;
    
     word=NULL;
    
     qDebug() << QString(QDir::toNativeSeparators(filepath));
    
     **/
    
    http://www.360doc.com/content/14/0227/16/7918060_356177077.shtml
    http://wenku.baidu.com/link?url=yZRGMW5aB8TrKoAYylebLyRcfXR9GTVcGpJ67-Ym3Q0Q-Q38GQz-W0iDhmpkCP_05LMwRBqadtWYRi3fgkrzW2Sw-WTUEyCLiddw0pOHoNm
    http://blog.sina.com.cn/s/blog_a6fb6cc90101gv2p.html
    http://blog.csdn.net/tingsking18/article/details/5677353

    http://www.quweiji.com/qt-%E6%93%8D%E4%BD%9Cword/
  • 相关阅读:
    Android中Intent传递对象的两种方法(Serializable,Parcelable)
    Android安全机制(2) Android Permission权限控制机制
    Android TextView中文字通过SpannableString来设置超链接、颜色、字体等属性
    finder怎么才能找到library
    Mac下Android Studio中获取SHA1和MD5
    andorid 自定义seekbar
    C# Sending data using GET or POST ZZ
    gmail
    load dll
    C# Read/Write another Process' Memory ZZ
  • 原文地址:https://www.cnblogs.com/findumars/p/5574534.html
Copyright © 2011-2022 走看看