O
O
Oleg Seledets2018-05-13 19:38:47
C++ / C#
Oleg Seledets, 2018-05-13 19:38:47

Set Excel document name via Qt Creator?

QString nameExc = ui->name_excel_file->text(); //считывание названия файла которое мы вводим
QAxObject* excel = new QAxObject("Excel.Application");
QAxObject *workbooks = excel->querySubObject( "Workbooks" );
QAxObject *shab = workbooks->querySubObject("Add()", "C:\\q\\"+nameExc+".xlsx");
QAxObject *mSheets = shab->querySubObject("Sheets");
QAxObject *StatSheet = mSheets->querySubObject("Item(const QVariant&)",QVariant("Лист1") );

As a result, he creates a new document in the My Documents folder, and calls it Book 1.
And how to replace Book 1, substitute the file name we specified. And if possible, indicate the path?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sumor, 2018-05-14
@oleja1ee7

After creating the book, make it a SaveAs .
PS. The Workbooks.Add method passes the parameters of the file with the template on the basis of which to create a new table, and not the name of the future workbook.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question