void onPrintBtn()
{
//1. open SaveDialog and get a file name
if (last_path_.isEmpty())
{
QString path = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation).at(0);
QDir::root().mkpath(path);
last_path_ = path;
}
QString default_dir_name = last_path_ + "/" + ui_->leIssueCode->text();
QString fileName = QFileDialog::getSaveFileName(this, "Save File",
default_dir_name,
"Word (*.doc)");
//save the current dir for next time
last_path_ = fileName.left(fileName.lastIndexOf('/'));
if(fileName.isEmpty()) {
qDebug() <<"There isn't a file name input "<dynamicCall("Add(QString)",inputHtml);
QAxObject *document=word.querySubObject("ActiveDocument");
if(!document) {
qDebug() << "Quering ActiveDocument failed " << endl;
return;
}
//save a doc using the input file name
document->dynamicCall("SaveAs (const QString&)", fileName);
//4. exit the word App
document->dynamicCall("Close (boolean)", false);
documents->dynamicCall("Close()");
word.dynamicCall("Quit()");
qDebug() << "The content is saved successfully" << endl;
tmpfile.close();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
PS:generateHtml函数得到字符串sample如下:
当日序列号:2 | 单号: |
CNY BOND TRADING (信用买卖)
TRADE DATE 成交日期2015-10-26 | TIME 时间17:11:00 |
BUYER(买入方) | SELLER(卖出方) |
NAME 名称:鹏扬投资北京(焦翠) CITY 分行/城市: | NAME 名称: CITY 分行/城市: | ||||||||||||||||||||
Brokerage 佣金:0.00 Broker 经纪人:傅尚杰sjfu 使用以下方式确认交易
| Brokerage 佣金:0.00 Broker 经纪人: 使用以下方式确认交易
|
CURRENCY 货币 | |
FACE AMOUNT 券面总额 | |
DIRTY PRICE 全价 | |
CLEAN PRICE 净价 | |
YIELD 收益率 | |
DELIVERY DATE 交割日 | 2015-10-27 |
SETTLEMENT TYPE 结算方式 | |
ISSUE CODE 债券代码 | 119175.SZ |
ISSUE 债券名称 | 科慧04 |
MATURITY DATE 债券到期日 | 2019-04-23 |
SPECIAL DETAILS 特别细节 |