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; }
void LabeledGridMap::loadFromImage(Image* img, double real_width, double resolution, double mapX, double mapY){ this->resolution=resolution; this->mapX=mapX; this->mapY=mapY; this->width=(int)(real_width/resolution); if(width != img->getWidth()) img->scale(width); this->height=img->getHeight(); int w,h,c; unsigned char*** img_buf = img->getPointerToImageMatrix(w,h,c); free(); allocate(w,h); for (int i=0; i<w; i++){ for (int j=0; j<h; j++){ if (img_buf[i][j][0] == (unsigned char)OBSTACLE) setCellValue(i,height-j-1,OBSTACLE); else if (img_buf[i][j][0] == (unsigned char)FREE) setCellValue(i,height-j-1,FREE); else setCellValue(i,height-j-1,UNKNOWN); } } }
void RKMatrixInput::clearSelectedCells () { RK_TRACE (PLUGIN); QItemSelectionRange range = display->getSelectionBoundaries (); if (!range.isValid ()) return; updating_tsv_data = true; for (int col = range.left (); col <= range.right (); ++col) { for (int row = range.top (); row <= range.bottom (); ++row) { setCellValue (row, col, QString ()); } } updating_tsv_data = false; updateAll (); }
void buildCellProcessList(table_cell *cell, cell_process **HEAD) { char *fnString; int size; int i = 0; fnString = getCellStringValue(cell, &size); while(i<size) { fnString[i] = toupper(fnString[i]); i++; } if (!buildFunction(fnString,size,1,cell,HEAD,-1)) { setCellValue(cell,createExccelVarFromString("#NÉV?\0")); } }
void RKMatrixInput::paste () { RK_TRACE (PLUGIN); int left = 0; int top = 0; QItemSelectionRange range = display->getSelectionBoundaries (); if (range.isValid ()) { left = range.left (); top = range.top (); } RKTextMatrix pasted = RKTextMatrix::matrixFromClipboard (); int height = allow_user_resize_rows ? pasted.numRows () : qMin (pasted.numRows (), row_count->intValue () - top); int width = allow_user_resize_columns ? pasted.numColumns () : qMin (pasted.numColumns (), column_count->intValue () - left); updating_tsv_data = true; for (int c = 0; c < width; ++c) { for (int r = 0; r < height; ++r) { setCellValue (r + top, c + left, pasted.getText (r, c)); } } updating_tsv_data = false; updateAll (); }
void UINumberPicker::updateDisplayList() { _selectedItem = nullptr; _itemsLayer->removeAllChildrenWithCleanup(true); sortChildrenArray.clear(); displayRect.size = getContentSize(); displayRect.origin = getParent()->convertToWorldSpace(getPosition()); int numOfCell = virtualItemCount + 2; m_middleCellIndex = (int)numOfCell/2; if (show_value < m_minValue || show_value > m_maxValue) { show_value = m_minValue; } int upIndex = show_value - 1; int downIndex = show_value; for (int i = 0; i < numOfCell; i++) { auto cell = PickerCell::create(); cell->setContentSize(Size(item_width, item_height)); cell->setDirection(_pickerDirection); switch (_pickerDirection) { case PickerDirection::VERTICAL: { cell->setPositionX(getContentSize().width/2); if (i <= m_middleCellIndex) { cell->setPositionY((m_middleCellIndex - i) * item_height); cell->setCellValue(downIndex); downIndex += 1; if (downIndex > m_maxValue) { downIndex = m_minValue; } } else { cell->setPositionY(i * item_height); if (upIndex < m_minValue) { upIndex = m_maxValue; } cell->setCellValue(upIndex); upIndex -= 1; } break; } case PickerDirection::HORIZONTAL: { cell->setPositionY(0); if (i <= m_middleCellIndex) { cell->setPositionX((m_middleCellIndex - i) * item_width); cell->setCellValue(downIndex); downIndex += 1; if (downIndex > m_maxValue) { downIndex = m_minValue; } } else { cell->setPositionX(i * item_width); if (upIndex < m_minValue) { upIndex = m_maxValue; } cell->setCellValue(upIndex); upIndex -= 1; } break; } default: break; } if (i == 0) { setCell(cell); } sortChildrenArray.push_back(cell); _itemsLayer->addChild(cell); } }