本文整理汇总了C++中QAxObject::querySubObject方法的典型用法代码示例。如果您正苦于以下问题:C++ QAxObject::querySubObject方法的具体用法?C++ QAxObject::querySubObject怎么用?C++ QAxObject::querySubObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAxObject
的用法示例。
在下文中一共展示了QAxObject::querySubObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeBody
void SportsmenReport::writeBody(const char *headers[], uint length)
{
sheet = openDocument();
for(uint i = 0; i < length; ++i)
{
QAxObject *range = sheet->querySubObject("Range(const QString&)",
QString('A'+i) + QString::number(1));
range->dynamicCall("SetValue(const QVariant&)", QObject::tr(headers[i]));
range->querySubObject("Font")->setProperty("Bold", true);
range->querySubObject("Borders")->setProperty("LineStyle", xlSingle);
}
int rowid = 2, fieldsCount = length;
while(query->next())
{
fieldsCount = query->record().count();
for(int i = 0; i < fieldsCount; ++i)
{
QAxObject *range = sheet->querySubObject("Range(const QString&)",
QString('A'+i) + QString::number(rowid));
range->dynamicCall("SetValue(const QVariant&)", QVariant(query->value(i).value<QString>()));
}
rowid++;
}
QAxObject *exported = sheet->querySubObject("Range(const QString&)",
(QString("A2:") + (QString('A'+(fieldsCount-1)) + QString::number(rowid-1))));
exported->querySubObject("Borders")->setProperty("LineStyle", xlSingle);
QAxObject *font = exported->querySubObject("Font");
font->setProperty("Name", QObject::tr("Arial"));
font->setProperty("Size", 10);
sheet->querySubObject("Columns")->dynamicCall("AutoFit()");
}
示例2: writeFooter
void PulkaReport::writeFooter()
{
uint offset = currentPage * pageHeight;
QAxObject *l1 = getRange(QString("A%1").arg(offset));
QAxObject *l2 = getRange(QString("H%1:J%1").arg(offset));
l1->dynamicCall("SetValue(const QVariant&)", QObject::tr("Гл. судья"));
l2->dynamicCall("Merge()");
l2->dynamicCall("SetValue(const QVariant&)", QObject::tr("Секретарь"));
l1->querySubObject("Borders(int)", xlEdgeBottom)->setProperty("LineStyle", xlSingle);
l2->querySubObject("Borders(int)", xlEdgeBottom)->setProperty("LineStyle", xlSingle);
l1->querySubObject("Font")->setProperty("Name", "Arial Cyr");
l2->querySubObject("Font")->setProperty("Name", "Arial Cyr");
l1->querySubObject("Font")->setProperty("Size", 11);
l2->querySubObject("Font")->setProperty("Size", 11);
uint fstMainRow = (currentPage - 1) * pageHeight + firstRecOffset,
lstMainRow = offset - 3;
QAxObject *grid = getRange(QString("C%1:K%2").arg(fstMainRow).arg(lstMainRow));
grid->querySubObject("Borders")->setProperty("LineStyle", xlContinious);
grid->querySubObject("Borders")->setProperty("Weight", xlHairline);
QAxObject *lCol = getRange(QString("A%1:B%2").arg(fstMainRow).arg(lstMainRow)),
*rCol = getRange(QString("L%1:M%2").arg(fstMainRow).arg(lstMainRow));
lCol->querySubObject("Font")->setProperty("Name", "Arial Cyr");
rCol->querySubObject("Font")->setProperty("Name", "Arial Cyr");
lCol->querySubObject("Font")->setProperty("Size", 12);
rCol->querySubObject("Font")->setProperty("Size", 12);
currentPage++;
}
示例3: printFile
void MyTable::printFile(const QString& fileName)
{
qDebug() << "PrintFile" << fileName;
#ifdef EXCEL
if (!excel->isNull()) {
if (excel->Workbooks()->Open(fileName)) {
Excel::_Worksheet sheet(excel->ActiveSheet());
sheet.PrintOut(1, 1, 1);
excel->Workbooks()->Close(); //ActiveWorkbook()->Close(false);
}
}
#else
QAxObject* excel = new QAxObject("Excel.Application", 0);
excel->dynamicCall("SetVisible(bool)", true);
QAxObject* workbooks = excel->querySubObject("Workbooks");
QAxObject* workbook = workbooks->querySubObject("Open(const QString&)", fileName);
QAxObject* sheets = workbook->querySubObject("Worksheets");
if (workbooks->dynamicCall("Count()").toInt()) {
QAxObject* sheet = sheets->querySubObject("Item(int)", 1);
sheet->dynamicCall("PrintOut(QVariant, QVariant, QVariant)", 1, 1, 1);
workbook->dynamicCall("Close()");
}
excel->dynamicCall("Quit()");
excel->deleteLater();
#endif
}
示例4: generateSchedule
bool ItemsList::generateSchedule()
{
if (!m_actualTable.isEmpty() && mainOrderActive )
{
setAnimationVisible(true);
emit animationVisible(getAnimationVisible());
if( setPath().isEmpty() ) {
runMsg("Nie wybrano lokalizacji.");
setAnimationVisible(false);
emit animationVisible(getAnimationVisible());
return false;
}
QAxObject* excel;
QAxObject* wbooks;
QAxObject* book;
QFileInfo scheduleFile("schedule.xlsm");
QVariant excelPath;
QVariant destPath;
excelPath = QVariant(scheduleFile.absoluteFilePath().replace("/", "\\\\"));
excel = new QAxObject("Excel.Application", this);
excel->setProperty("Visible", false);
excel->setProperty("DisplayAlerts",0);
wbooks = excel->querySubObject("Workbooks");
book = wbooks->querySubObject("Open (const QString&)", excelPath);
destPath = excel->dynamicCall("Run(QVariant)", QVariant("runMacro"));
book->dynamicCall("Close()");
excel->dynamicCall("Quit()");
runMsg("Wygenerowano harmonogram",destPath.toString());
delete book;
delete wbooks;
delete excel;
setAnimationVisible(false);
emit animationVisible(getAnimationVisible());
csvFile->remove();
tableDialog->model->clear();
mainOrderActive = false;
return true;
}
else if(m_actualTable.isEmpty() || !mainOrderActive )
{
runMsg("Zamówienie jest puste.");
return false;
}
return false;
}
示例5: QAxObject
QAxObject *BaseReport::openDocument()
{
excel = new QAxObject("Excel.Application", 0);
excel->dynamicCall("SetVisible(bool)", true);
QAxObject *workbooks = excel->querySubObject("Workbooks");
QAxObject *workbook = workbooks->querySubObject("Add()");
QAxObject *sheet = workbook->querySubObject("ActiveSheet");
sheet->dynamicCall( "Select()" );
return sheet;
}
示例6: on_btnExport_clicked
void MainWindow::on_btnExport_clicked()
{
QDir dir(QDir::currentPath());
QDate date;
QSettings config(dir.currentPath()+"//app.ini",QSettings::IniFormat);
QString path = config.value("/SETTINGS/path").toString();
QString fileName = QFileDialog::getSaveFileName(this,tr("保存文件"),path + "/" + date.currentDate().toString("yyyy-MM-dd")+ui->cbWareH->currentText()+".xls",tr("Microsoft Office 2003(*.xls)"));
if(fileName.isEmpty()){
QMessageBox::critical(0,tr("错误"),tr("要保存的文件名为空"));
return;
}
QSqlQuery query;
query.exec(QString("execute dbo.pr_report_jxc_item;1 @as_from = '%1', @as_to = '%2', @as_branch = '%3', @as_itemcls = '%'")
.arg(date.currentDate().toString("yyyy-MM-dd"))
.arg(date.currentDate().toString("yyyy-MM-dd"))
.arg(ui->cbWareH->currentData().toString()));
QAxObject *excel = new QAxObject("Excel.Application");
if(!excel){
QMessageBox::critical(0,tr("错误"),tr("找不到Excel组件!"));
delete excel;
return;
}
excel->dynamicCall("SetVisible(bool)",false);
excel->setProperty("Visible", false);
excel->setProperty("DisplayAlerts", false);
QAxObject *workbooks = excel->querySubObject("WorkBooks");
workbooks->dynamicCall("Add");
QAxObject *workbook = excel->querySubObject("ActiveWorkBook");
QAxObject *worksheets = workbook->querySubObject("Sheets");
QAxObject *worksheet = worksheets->querySubObject("Item(int)",1);
int row = 1;
while(query.next()){
setCellValue(worksheet,row,"A","'"+query.value("cItem_C").toString());
setCellValue(worksheet,row,"B","'"+query.value("cItem_N").toString());
setCellValue(worksheet,row,"C","0");
setCellValue(worksheet,row,"D",query.value("nSettleQty"));
row ++;
};
workbook->dynamicCall("SaveAs(const QString&)",QDir::toNativeSeparators(fileName));
config.setValue("/SETTINGS/path",fileName.left(fileName.lastIndexOf("/")));
QMessageBox::information(this,tr("操作成功"),tr("保存成功!"));
workbook->dynamicCall("Close()");
worksheet->clear();
excel->dynamicCall("Quit()");
delete excel;
}
示例7: getUsedRange
void QEXCEL::getUsedRange(int *topLeftRow, int *topLeftColumn, int *bottomRightRow, int *bottomRightColumn)
{
QAxObject *usedRange = sheet->querySubObject("UsedRange");
*topLeftRow = usedRange->property("Row").toInt();
*topLeftColumn = usedRange->property("Column").toInt();
QAxObject *rows = usedRange->querySubObject("Rows");
*bottomRightRow = *topLeftRow + rows->property("Count").toInt() - 1;
QAxObject *columns = usedRange->querySubObject("Columns");
*bottomRightColumn = *topLeftColumn + columns->property("Count").toInt() - 1;
}
示例8: showInWindowsShell
bool showInWindowsShell(const QString &filePath, bool deselect) {
QFileInfo appFI(filePath);
auto matchPath = appFI.dir().path().toLower();
auto matchName = appFI.fileName().toLower();
QAxObject shellApp("Shell.Application");
QAxObject *windows = shellApp.querySubObject("Windows()");
windows->disableMetaObject();
auto count = windows->dynamicCall("Count()").toInt();
qDebug() << count;
for (int i = 0; i < count; ++i) {
QAxObject *win = windows->querySubObject("Item(QVariant)", {i});
win->disableMetaObject();
auto program = win->dynamicCall("FullName()").toString();
QFileInfo programFI(program);
if (programFI.baseName().toLower() != "explorer") continue;
auto url = win->dynamicCall("LocationURL()").toUrl();
if (!url.isLocalFile()) continue;
auto path = url.path().mid(1).toLower();
if (path != matchPath) continue;
QAxObject *doc = win->querySubObject("Document()");
QAxObject *folder = doc->querySubObject("Folder()");
folder->disableMetaObject();
QAxObject *folderItems = folder->querySubObject("Items()");
folderItems->disableMetaObject();
QAxObject *ourEntry = {};
int count = folderItems->dynamicCall("Count()").toInt();
for (int j = 0; j < count; j++) {
QAxObject *entry = folderItems->querySubObject("Item(QVariant)", j);
entry->disableMetaObject();
auto name = entry->dynamicCall("Name()").toString().toLower();
if (name == matchName) ourEntry = entry;
}
if (ourEntry) {
if (false)
ourEntry->dynamicCall("InvokeVerb(QVariant)", QVariant()); // open etc.
auto rc = doc->dynamicCall("SelectItem(QVariant, int)", ourEntry->asVariant(),
SVSI_SELECT | (deselect ? SVSI_DESELECTOTHERS : 0));
auto hwnd = win->dynamicCall("HWND()").toLongLong();
BringWindowToTop(HWND(hwnd));
return true;
}
}
return false;
}
示例9: return
QAxObject * ExcelOnglet::recupererPremiereCelluleVidePremiereColonne()
{
QAxObject * derniereCellulePleinePremiereColonne =
recupererDerniereCelluleNonVidePremiereColonne();
return (QAxObject *)
derniereCellulePleinePremiereColonne->querySubObject( "Offset(int, int)", 1, 0 );
}
示例10: init_word
//AC.template.verifiedRecord
void MainWidget::init_word()
{
QAxWidget word("Word.Application");
word.setProperty("Visible", false);//隐式的打开一个word应用程序
QAxObject * documents = word.querySubObject("Documents"); //获取所有工作文档
documents->dynamicCall("Add (void)");//创建一个word文档
QAxObject * document = word.querySubObject("ActiveDocument"); //获取当前激活的文档
QAxObject *selection = word.querySubObject("Selection"); //写入文件内容
QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间
QString str = time.toString("yyyy-MM-dd hh:mm:ss ddd"); //设置显示格式
selection->dynamicCall("TypeText(const QString&)","hello"+str);
//设置保存
QVariant newFileName("e:/test.doc"); //存放位置和名称
QVariant fileFormat(1); //文件格式
QVariant LockComments(false);
QVariant Password(""); //设置打开密码
QVariant recent(true);
QVariant writePassword("");
QVariant ReadOnlyRecommended(false);
document->querySubObject("SaveAs(const QVariant&, const QVariant&,const QVariant&, const QVariant&, const QVariant&, const QVariant&,const QVariant&)", newFileName, fileFormat, LockComments, Password, recent, writePassword, ReadOnlyRecommended);
document->dynamicCall("Close (boolean)", true); //关闭文档
word.dynamicCall("Quit (void)");//退出
}
示例11: getUsedRowsCount
int QEXCEL::getUsedRowsCount()
{
QAxObject *usedRange = sheet->querySubObject("UsedRange");
int topRow = usedRange->property("Row").toInt();
QAxObject *rows = usedRange->querySubObject("Rows");
int bottomRow = topRow + rows->property("Count").toInt() - 1;
return bottomRow;
}
示例12: CellValue
QString QExcel::CellValue(int sheetIdx, int x, int y){
if( sheetIdx < 1 || x < 1 || y < 1)
return NULL;
QAxObject* sheet = _sheets->querySubObject( "Item( int )", sheetIdx );
QAxObject* cell = sheet->querySubObject("Cells(int,int)", y, x);
QString ret = cell->property("Value").toString();
return ret;
}
示例13: setCellFontBold
void QEXCEL::setCellFontBold(int row, int column, bool isBold)
{
QString cell;
cell.append(QChar(column - 1 + 'A'));
cell.append(QString::number(row));
QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
range = range->querySubObject("Font");
range->setProperty("Bold", isBold);
}
示例14: setCellFontSize
void QEXCEL::setCellFontSize(int row, int column, int size)
{
QString cell;
cell.append(QChar(column - 1 + 'A'));
cell.append(QString::number(row));
QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
range = range->querySubObject("Font");
range->setProperty("Size", size);
}
示例15: on_RSMV_buildFrom_PsBtn_clicked
void MainWidget::on_RSMV_buildFrom_PsBtn_clicked()
{
QString strPath=getTemplatePath();
QFile file(strPath);
//qDebug()<<strPath;
if (!file.exists())
{
show_MsBox(QString::fromUtf8("找不到报表模板路径"),3000);
}
#if 1
QAxWidget* temp_AxWidget = new QAxWidget("Word.Application");
temp_AxWidget->setProperty("Visible", true); //新建一个word应用程序,并设置为可见
QAxObject* documents = temp_AxWidget->querySubObject("Documents"); //获取所有的工作文档
documents->dynamicCall("Open(QVariant)",strPath ); //路径不对打开奔溃
QAxObject *selection = temp_AxWidget->querySubObject("Selection");
QAxObject *find = selection->querySubObject("Find");
QList<QVariant> list2; //*****Find Word http://technet.microsoft.com/zh-cn/library/ff193977
list2.append("{cUserName}"); //find text
list2.append(QVariant());//2
list2.append(QVariant());//3
list2.append(QVariant());//4
list2.append(QVariant());//5
list2.append(QVariant());//6
list2.append(QVariant());//7
list2.append(QVariant());//8
list2.append(QVariant());//9
list2.append(QString::fromUtf8("深圳市星龙科技")); //replace text
list2.append(2);//replace all:2
list2.append(QVariant());//12
list2.append(QVariant());//13
list2.append(QVariant());//14
list2.append(QVariant());//15
replaceDocTypeList replaceDocTypeList_Data; //装载搜索内容和替换内容的列表
fillReplaceDocTypeList(ui->from_information_TbWidget,&replaceDocTypeList_Data);
for (int i = 0; i < replaceDocTypeList_Data.count(); i++)
{
list2.replace(0, replaceDocTypeList_Data.at(i).searchStr);
list2.replace(9, replaceDocTypeList_Data.at(i).replaceStr);
find->dynamicCall("Execute (QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant& ,QVariant& ,QVariant& , QVariant&, QVariant&, QVariant&, QVariant&)", list2);
//qDebug()<<replaceDocTypeList_Data.at(i).replaceStr;
}
#endif
// documents->dynamicCall("Save()");//保存
// documents->dynamicCall("Close(boolean)", true);//关闭文本窗口
// temp_AxWidget->dynamicCall("Quit(void)");//退出word
}