void KviCanvasItemPropertiesWidget::editItem(QCanvasItem * it)
	{
		if(!it)
		{
			for(int i=0;i<numRows();i++)
			{
				clearCell(i,0);
				clearCell(i,1);
				clearCellWidget(i,1);
			}
			setNumRows(0);
			return;
		}

		QMap<QString,QVariant> * m = 0;

		switch(KVI_CANVAS_RTTI_CONTROL_TYPE(it))
		{
			case KVI_CANVAS_RTTI_CONTROL_TYPE_RECTANGLE:
				m = ((KviCanvasRectangleItem *)it)->properties();
			break;
			case KVI_CANVAS_RTTI_CONTROL_TYPE_LINE:
				m = ((KviCanvasLine *)it)->properties();
			break;
			case KVI_CANVAS_RTTI_CONTROL_TYPE_POLYGON:
				m = ((KviCanvasPolygon *)it)->properties();
			break;
		}

		if(!m)
		{
			editItem(0);
			return;
		}

		for(int i=0;i<numRows();i++)
		{
			clearCell(i,0);
			clearCell(i,1);
			clearCellWidget(i,1);
		}

		setNumRows(m->count());

		QTableItem * item;

		int idx = 0;

		for(QMap<QString,QVariant>::ConstIterator iter = m->begin();iter != m->end();++iter)
		{
			item = new QTableItem(this,QTableItem::Never,iter.key().toUtf8().data());
			setItem(idx,0,item);
			item = new KviVariantTableItem(this,iter.data());
			setItem(idx,1,item);
			idx++;
		}

	}
void Table::sortColumn( int col, bool ascending, bool /*wholeRows*/ )
{
    // sum row should not be sorted, so get rid of it for now
    clearCell( numRows() - 1, 0 );
    clearCell( numRows() - 1, 1 );
    // do sort
    QTable::sortColumn( col, ascending, TRUE );
    // re-insert sum row
    recalcSum( 0, 1 );
}
Exemple #3
0
int hasSolution(sudokuGrid game){
    int solved;
    cell candidateCell;
    value trialValue;

    if(isFull(game)){
        solved = TRUE;
    }else{
        candidateCell = getEmptyCell(game);
        trialValue = MIN_VALUE;
        solved = FALSE;
        while(!solved && (trialValue <= MAX_VALUE)){
            if(isLegal(game, candidateCell, trialValue)){
                setCell(game, candidateCell, trialValue);

                if(hasSolution(game)){
                    solved = TRUE;
                }else{
                    clearCell(game, candidateCell);
                }
            }
            trialValue++;
        }
    }
    return solved;
}
Exemple #4
0
	void clearCell(HashCell *currentCell){
		if (currentCell == nullptr)
			return;
		clearCell(currentCell->next);
		deleteString(currentCell->key);
		delete currentCell;
	}
void mgsCooperSymbols::drawGrid(float x, float y) {
  ofPushStyle();
  clearCell(shiftCounter-1,rowCounter,gw+2,gh);
  drawCursor();
  ofSetColor(symbolColor);
  ofNoFill();
  if(randomStrokeP) randomStroke();
  if (!singleShapesP) {
    switch((int)ofRandom(1, numberOfShapes+1)) {
      case 1:
        drawSquare(x+shiftCounter, y+rowCounter, gw);
        break;
      case 2:
        drawTri(x+shiftCounter, y+rowCounter, gw);
        break;
      case 3:
        drawCircle(x+shiftCounter+gw/2, y+rowCounter+gh/2, gw/2);
        break;
    }
  } else {
    switch(numberOfShapes) {
      case 1:
        drawSquare(x+shiftCounter, y+rowCounter, gw);
        break;
      case 2:
        drawTri(x+shiftCounter, y+rowCounter, gw);
        break;
      case 3:
        drawCircle(x+shiftCounter+gw/2, y+rowCounter+gw/2, gw/2);
        break;
    }
  }
  ofPopStyle();
}
Exemple #6
0
bool DataGrid::clearCellData(int row, int col)
{
	if (!IsReadOnly(row, col) && !GetCellValue(row, col).IsEmpty()) {
		clearCell(row, col);
		wxGridEvent ev(GetId(), wxEVT_GRID_CELL_CHANGED, this, row, col);
		wxPostEvent(this, ev);
	}
	return false;
}
Exemple #7
0
void		Map::clearExplode(unsigned int index)
{
  int		x = _bomb[index]->getX();
  int		y = _bomb[index]->getY();
  int		range = _bomb[index]->getRangeBomb();

  clearCell(index, y, x);
  for (int i = 1; i < range + 1; i++)
    {
      if ((_map[y][x + i] == Tile::EXPLOSION)
	  || (_map[y][x + i] == Tile::EXPLOSION_POWERUP))
	clearCell(index, y, x + i);
      else
	break;
    }
  for (int i = 1; i < range + 1; i++)
    {
      if ((_map[y][x - i] == Tile::EXPLOSION)
	  || (_map[y][x - i] == Tile::EXPLOSION_POWERUP))
	clearCell(index, y, x - i);
      else
	break;
    }
  for (int i = 1; i < range + 1; i++)
    {
      if ((_map[y + i][x] == Tile::EXPLOSION)
	  || (_map[y + i][x] == Tile::EXPLOSION_POWERUP))
	clearCell(index, y + i, x);
      else
	break;
    }
  for (int i = 1; i < range + 1; i++)
    {
      if ((_map[y - i][x] == Tile::EXPLOSION)
	  || (_map[y - i][x] == Tile::EXPLOSION_POWERUP))
	clearCell(index, y - i, x);
      else
	break;
    }
}
Exemple #8
0
void MTable::setCellContentFromEditor( int row, int col )
{
    QWidget *editor = cellWidget( row, col );
    if ( !editor ) return;
    clearCell( row, col );
    if ( editor->inherits( "QComboBox" ) ){
	  QString str = ((QComboBox*)editor )->currentText();
                //if ( str == "no medium" ) str = "";
	  setText( row, col, str );
    }
    else if ( editor->inherits( "QLineEdit" ) )
	   setText( row, col, ( (QLineEdit*)editor )->text() );
}
void makeAllWalls(void) {
	unsigned r, c;
	unsigned row, col;
	for (r = 0; r < MATRIX_SIZE; r += 1) {
		for (c = 0; c < MATRIX_SIZE; c += 1) {
			maze[r][c] = WALL;
		}
	}
	for (row = 0; row < MAZE_SIZE; row += 1) {
		for (col = 0; col < MAZE_SIZE; col += 1) {
			clearCell(row, col);
		}
	}
}
Exemple #10
0
void QEXCEL::mergeSerialSameCellsInAColumn(int column, int topRow)
{
    int a,b,c,rowsCount;
    getUsedRange(&a, &b, &rowsCount, &c);

    int aMergeStart = topRow, aMergeEnd = topRow + 1;

    QString value;
    while(aMergeEnd <= rowsCount)
    {
        value = getCellValue(aMergeStart, column).toString();
        while(value == getCellValue(aMergeEnd, column).toString())
        {
            clearCell(aMergeEnd, column);
            aMergeEnd++;
        }
        aMergeEnd--;
        mergeCells(aMergeStart, column, aMergeEnd, column);

        aMergeStart = aMergeEnd + 1;
        aMergeEnd = aMergeStart + 1;
    }
}
Exemple #11
0
void
iterateLifeKernel(
    LIFE_T *life,
    int32_t thread)
{
    uint8_t *cell = life->field +
                    (life->heightRange[thread].startHeight * life->width);

    int32_t row;
    for (row = life->heightRange[thread].startHeight ;
         row < life->heightRange[thread].endHeight ;
         row++)
    {
        int32_t col;
        for (col = 0 ; col < life->width ; col++)
        {
            uint8_t neighbours = *cell >> 1;

            if (*cell & 0x01)
            {
                if ((neighbours != 2) && (neighbours != 3))
                {
                    clearCell(life, col, row);
                }
            }
            else
            {
                if (neighbours == 3)
                {
                    setCell(life, col, row);
                }
            }

            ++cell;
        }
    }
}
Exemple #12
0
	void clearTable(HashTable *hashTable){
		for (int i = 0; i < base; i++){
			clearCell(hashTable->cells[i]);
		}
		delete hashTable;
	}
Exemple #13
0
MainWindow::MainWindow(
  QWidget *parent)
  : QMainWindow(parent),
    ui(new Ui::MainWindow),
    aboutForm(0),
    documentationForm(0),
    preferencesForm(0),
    toolBar(0),
    formulaInput(0),
    cellLabel(0),
    optionsButton(0),
    scanButton(0),
    csvModel(0),
    table(0),
    barcodeViewForm(0),
    optionsDialog(0)
{
  ui->setupUi(this);
  setAttribute(Qt::WA_Maemo5StackedWindow);

  barcodeViewForm = new LasBarcodeViewForm(this);
  optionsDialog = new LasOptionsDialog(this);
  preferencesForm = new LasPreferencesForm(this);

  toolBar = new QToolBar();
  addToolBar(toolBar);

  formulaInput = new QLineEdit();

  cellLabel = new QLabel(toolBar);
  cellLabel->setMinimumSize(80, 0);

  optionsButton = new QPushButton();
  optionsButton->setIcon(QIcon(":/icons/dash.svg"));

  scanButton = new QPushButton();
  scanButton->setIcon(QIcon(":/icons/plus.svg"));

  toolBar->addWidget(scanButton);
  toolBar->addWidget(cellLabel);
  toolBar->addWidget(formulaInput);
  toolBar->addWidget(optionsButton);

  table = new LasSheet(this);
  ui->centralLayout->addWidget(table);

  QSettings settings("pietrzak.org", "Lasagne");

  if (settings.contains("currentFilename"))
  {
    currentFilename = settings.value("currentFilename").toString();
  }
  else
  {
    currentFilename = "/home/user/MyDocs/.documents/Lasagne.csv";
  }
  
  csvModel = new LasCsvModel(currentFilename, this, true);

  table->setModel(csvModel);

  table->resizeAllCells();

//  statusBar();
/*
  connect(
    table,
    SIGNAL(currentItemChanged(QTableWidgetItem*, QTableWidgetItem*)),
    this,
    SLOT(updateStatus(QTableWidgetItem*)));
*/

  connect(
    table->selectionModel(),
    SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
    this,
    SLOT(updateToolbar(const QModelIndex &)));

/*
  connect(
    table,
    SIGNAL(itemChanged(QTableWidgetItem*)),
    this,
    SLOT(updateStatus(QTableWidgetItem*)));
*/

  connect(
    formulaInput,
    SIGNAL(returnPressed()),
    this,
    SLOT(returnPressed()));

/*
  connect(
    table,
    SIGNAL(itemChanged(QTableWidgetItem*)),
    this,
    SLOT(updateLineEdit(QTableWidgetItem*)));
*/

//  table->updateColor(0);

  connect(
    optionsButton,
    SIGNAL(clicked()),
    optionsDialog,
    SLOT(exec()));

  connect(
    scanButton,
    SIGNAL(clicked()),
    this,
    SLOT(displayBarcodeForm()));

  connect(
    barcodeViewForm,
    SIGNAL(barcodeFound(QString, QString, QString, QString, QString)),
    this,
    SLOT(addNewRow(QString, QString, QString, QString, QString)));

/*
  connect(
    optionsDialog,
    SIGNAL(editFormula()),
    this,
    SLOT(something()));
*/

  connect(
    optionsDialog,
    SIGNAL(clearCell()),
    this,
    SLOT(clearCurrentCell()));

  connect(
    optionsDialog,
    SIGNAL(removeRow()),
    this,
    SLOT(removeCurrentRow()));

  connect(
    optionsDialog,
    SIGNAL(loadFile()),
    this,
    SLOT(load()));

  connect(
    optionsDialog,
    SIGNAL(saveFile()),
    this,
    SLOT(save()));

  connect(
    optionsDialog,
    SIGNAL(saveFileAs()),
    this,
    SLOT(saveAs()));

  // Preferences form:
  connect(
    preferencesForm,
    SIGNAL(beepPreference(bool)),
    barcodeViewForm,
    SLOT(setBeepPref(bool)));

  // Initialize beep preference:
  barcodeViewForm->setBeepPref(preferencesForm->getBeepPref());

  connect(
    preferencesForm,
    SIGNAL(ignoreLensCover(bool)),
    barcodeViewForm,
    SLOT(updateIgnoreCover(bool)));

  barcodeViewForm->updateIgnoreCover(preferencesForm->getIgnoreCover());
}
Exemple #14
0
//     My own version of the table's actions
//    In principle it does the same as QTable, but
//       deletes selected cells
//      closes application on ESCAPE
bool MTable::eventFilter( QObject *o, QEvent *e )
{
    if ( !o || !e )
	return QScrollView::eventFilter( o, e );

    //QWidget *editorWidget = cellWidget( currentRow(), currentColumn() );

    switch ( e->type() ) {
    case QEvent::KeyPress:
	if ( !isEditing() ) {
                  QKeyEvent *ke = (QKeyEvent*)e;
	    if ( ke->key() == Key_Escape ) {
                           QApplication::sendEvent( parentWidget ( FALSE ) , e );
		return TRUE;
	    }

	    if ( ke->key() == Key_Return || ke->key() == Key_Enter ) {
		if ( currentRow() >= numRows() - 1 ){
		    setUpdatesEnabled( false );
		    setNumRows( numRows() + 10 );
		    setUpdatesEnabled( true );
		}
	        activateNextCell();
                ensureCellVisible ( currentRow(), currentColumn() );
		return TRUE;
	    }

	    if ( ke->key() == Key_Delete ) {
	            if (numSelections() > 0) {
		    QTableSelection ts = selection( currentSelection() );
		    for ( int icol = ts.leftCol(); icol <= ts.rightCol(); icol++){
			for ( int irow = ts.topRow(); irow <= ts.bottomRow(); irow++){
                                         clearCell( irow, icol );
		      }
		    }
		    setCurrentCell ( ts.anchorRow(), ts.anchorCol() );
		    clearSelection ( TRUE );
		}
	              else {
                                 clearCell( currentRow(), currentColumn() );
	              }
		return TRUE;
	    }
	    if ( ke->key() == Key_C && ( ke->state() & ControlButton ) == ControlButton ) {
	              QString cellText;
		 itemCopy.clear();
		if (numSelections() > 0) {
	                  QTableSelection ts;
		    ts = selection( currentSelection() );
		    for ( int irow = ts.topRow(); irow <= ts.bottomRow(); irow++){
		      for ( int icol = ts.leftCol(); icol <= ts.rightCol(); icol++){
		             cellText = text( irow, icol );
                                         if ( !cellText.isEmpty() )
                                              itemCopy.push_back( cellText.latin1() );
		             else
                                              itemCopy.push_back( "" );
		      }
		    }
		}
		else {
	                   cellText = text( currentRow(), currentColumn() );
                                 if ( !cellText.isEmpty() )
                                              itemCopy.push_back( cellText.latin1() );
                                 else      itemCopy.push_back( "" );
		}
		return TRUE;
	    }
	    if ( ke->key() == Key_V && ( ke->state() & ControlButton ) == ControlButton ) {
		if ( numSelections() > 0 && itemCopy.size() > 0 ) {
		    QTableSelection ts = selection( currentSelection() );
		    uint icount;
		    for ( int irow = ts.topRow(); irow <= ts.bottomRow(); irow++){
		       for ( int icol = ts.leftCol(); icol <= ts.rightCol(); icol++){
		             //icount = (icol - ts.leftCol())*(ts.bottomRow() - ts.topRow()+1) + irow-ts.topRow();
		             icount = (irow - ts.topRow())*(ts.rightCol() - ts.leftCol()+1) + icol-ts.leftCol();
                                         if ( icount < itemCopy.size() )
                                            setText( irow, icol, (itemCopy[icount]).c_str() );
		      }
		    }
		}
		else {
		    if ( itemCopy.size() > 0 ) // there was not selection, copy first item only
		         setText( currentRow(), currentColumn(), (itemCopy[0]).c_str() );
		}
		return TRUE;
	    }
	    if ( ke->key() == Key_X && ( ke->state() & ControlButton ) == ControlButton ) {
		QString cellText;
		if (numSelections() > 0) {
		    itemCopy.clear();
		   QTableSelection ts;
		    ts = selection( currentSelection() );
		    for ( int irow = ts.topRow(); irow <= ts.bottomRow(); irow++){
		      for ( int icol = ts.leftCol(); icol <= ts.rightCol(); icol++){
		             cellText = text( irow, icol );
                                         if ( !cellText.isEmpty() )
                                              itemCopy.push_back( cellText.latin1() );
		             else
                                              itemCopy.push_back( "" );
                                         clearCell( irow, icol );
		      }
		    }
		    setCurrentCell ( ts.anchorRow(), ts.anchorCol() );
		    clearSelection ( TRUE );
		}
		else {
	                   cellText = text( currentRow(), currentColumn() );
                                 if ( !cellText.isEmpty() )
                                              itemCopy.push_back( cellText.latin1() );
                                 else      itemCopy.push_back( "" );
                                clearCell( currentRow(), currentColumn() );
		}
		return TRUE;
	    }

	    if ( currentColumn() == 0 &&
	         ctype == ComboBox   &&
                       ke->key() != Key_Left  && ke->key() != Key_Right &&
                       ke->key() != Key_Up  && ke->key() != Key_Down &&
                       ke->key() != Key_Control && ke->key() != Key_Alt &&
                       ke->key() != Key_Shift ) {
		//QApplication::beep ();
		keyPressEvent( (QKeyEvent*)e );
		return true;
	    }
	}
        else{
            QKeyEvent *ke = (QKeyEvent*)e;
	    if ( ke->key() == Key_Return || ke->key() == Key_Enter ) {
                stopEditing();
		if ( currentRow() >= numRows() - 1 ){
		    setUpdatesEnabled( false );
		    setNumRows( numRows() + 10 );
		    setUpdatesEnabled( true );
		}
                //else {stopEditing();}
                activateNextCell();
		return true;
	    }
        }
        break;
    default:
	break;
    }

    return QTable::eventFilter( o, e ) ;
}
void mgsCooperSymbols::debugGrid(){
  if(debug && animated) {
   clearCell(shiftCounter-1, rowCounter, gw+1, gh);
  }
}
Exemple #16
0
void __fastcall TForm1::actCalcClassificationExecute(TObject *Sender)
{
	if(!MakeBackup()) {
		Log->Lines->Add("Не удалось создать резервную копию файла");
		return;
	}

	Variant app = Variant::CreateObject("Excel.Application");
	app.OlePropertySet("Visible", true);
	Variant excel = app.OlePropertyGet("Workbooks").OleFunction("Open", WideString(m_strFileName.c_str()));
	Variant vSheets = excel.OlePropertyGet("Worksheets");
	Variant vSheet = vSheets.OlePropertyGet("Item",m_nPageClassification);
	UnicodeString strPageName = vSheet.OlePropertyGet("Name");
	if (strPageName.UpperCase() != UnicodeString("классификации").UpperCase()) {
	   app.OleProcedure("Quit");
	   MessageBox (Handle, UnicodeString(L"Не верное имя страницы").c_str(), L"prompt", MB_OK);
	   return;
	};

	std::vector<exlClass> classes;
	ReadClassifications(vSheet, classes);

	std::vector<exlMonth> months;
	Variant vSheetMonth;
	double fSumSum = 0;
	for (unsigned int i = 0; i < m_vMonth.size(); i++) {
		if (cmbMonth->Text == m_vMonth[i].Name) {
			int nMonthPage = m_vMonth[i].Number;
			vSheetMonth = vSheets.OlePropertyGet("Item", nMonthPage);
			ReadMonth(vSheetMonth, months);
			ReadMonthSum(vSheetMonth, fSumSum);
		}
	}

	Log->Lines->Add("Произвожу расчет...");
    ProgressBar1->Max = months.size();
	ProgressBar1->Min = 0;
	double nSumHand = 0;

	std::vector<exlSumClass> vSumClasses;
	for (unsigned int i = 0; i < months.size(); i++) {
		ProgressBar1->Position = i;
		int nFound = 0;
		nSumHand += months[i].Price;
		for (unsigned int iC = 0; iC < classes.size(); iC++) {
			if (nFound == 0 && classes[iC].Name.UpperCase() == months[i].Name.UpperCase()) {
				months[i].Class = classes[iC].Class;
				months[i].LinkToClassification = createHyperLinkToClassification(classes, iC);
				nFound++;
			}
		}
		if (nFound == 0) {
			months[i].Class = m_sUnknownClass;
		}

		nFound = 0;
		for (unsigned int iC = 0; iC < vSumClasses.size(); iC++) {
			if (vSumClasses[iC].Name.UpperCase() == months[i].Class.UpperCase()) {
				vSumClasses[iC].Sum += months[i].Price;
				nFound++;
			}
		}
		if (nFound == 0) {
		   exlSumClass sm;
		   sm.Name = months[i].Class;
		   sm.Sum = months[i].Price;
		   vSumClasses.push_back(sm);
		}
	}

	/*for (unsigned int i = 0; i < vSumClasses.size(); i++) {
		Log->Lines->Add(vSumClasses[i].Name + " = " + FloatToStr(vSumClasses[i].Sum));
	}*/

	Log->Lines->Add("Готово.");

	Log->Lines->Add("Сортирую классификации...");
	ProgressBar1->Max = 100;
	ProgressBar1->Min = 0;

	{
		int nPermutation = 1;
		while (nPermutation > 0) {
			nPermutation = 0;
			for (unsigned int iC = 0; iC < vSumClasses.size()-1; iC++) {
				ProgressBar1->Position = (ProgressBar1->Position+1) % ProgressBar1->Max;
				Application->ProcessMessages();
				if (vSumClasses[iC].Name.UpperCase() > vSumClasses[iC+1].Name.UpperCase()) {
					exlSumClass buf = vSumClasses[iC];
					vSumClasses[iC] = vSumClasses[iC+1];
					vSumClasses[iC+1] = buf;
					nPermutation++;
				}
			}
		}
		ProgressBar1->Position = 0;
    }
	Log->Lines->Add("Готово.");

	Log->Lines->Add("Очистка старых данных");
	ProgressBar1->Max = 100;
	ProgressBar1->Min = 0;

	// clear sum classes, 11,12
	{
		bool b = true;
		int nRow = 1;
		while (b) {
			b = false;
			nRow++;
			ProgressBar1->Position = (ProgressBar1->Position+1) % ProgressBar1->Max;
			Application->ProcessMessages();

			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OleProcedure("ClearFormats");
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OleProcedure("ClearFormats");

			UnicodeString sValue11 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertyGet("Value");
			UnicodeString sValue12 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertyGet("Value");

			clearCell(vSheetMonth, nRow, 11);
			clearCell(vSheetMonth, nRow, 12);

			if (sValue12.Trim().Length() > 0 || sValue11.Trim().Length() > 0) {
				b = true;
			}
		}
		ProgressBar1->Position = 0;
	}

	// clear 14,15,16,17
	{
		bool b = true;
		int nRow = 1;
		while (b) {
			b = false;
			nRow++;
			ProgressBar1->Position = (ProgressBar1->Position+1) % ProgressBar1->Max;
			Application->ProcessMessages();

			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OleProcedure("ClearFormats");
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,15).OleProcedure("ClearFormats");
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OleProcedure("ClearFormats");
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OleProcedure("ClearFormats");

			UnicodeString sValue14 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OlePropertyGet("Value");
			UnicodeString sValue15 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,15).OlePropertyGet("Value");
			UnicodeString sValue16 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertyGet("Value");
			UnicodeString sValue17 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OlePropertyGet("Value");

			clearCell(vSheetMonth, nRow, 14);
			clearCell(vSheetMonth, nRow, 15);
			clearCell(vSheetMonth, nRow, 16);
			clearCell(vSheetMonth, nRow, 17);

			if (
				sValue14.Trim().Length() > 0
				|| sValue15.Trim().Length() > 0
				|| sValue16.Trim().Length() > 0
				|| sValue17.Trim().Length() > 0
			) {
				b = true;
			}
		}
		ProgressBar1->Position = 0;
	}


	Log->Lines->Add("Запись новых данных");
	{
		double nSum = 0;
		int nRow = 2;
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertySet("Value", WideString("Класс"));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("Value", WideString("Сумма"));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertyGet("Font").OlePropertySet("Bold", true);
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertyGet("Font").OlePropertySet("Bold", true);
		vSheetMonth.OlePropertyGet("Columns", WideString("K")).OlePropertySet("ColumnWidth", 20);
		vSheetMonth.OlePropertyGet("Columns", WideString("L")).OlePropertySet("ColumnWidth", 15);
		setBorders(vSheetMonth, nRow, 11);
		setBorders(vSheetMonth, nRow, 12);
		setColor(vSheetMonth, nRow, 11, RGBToInt(240, 230, 140));
		setColor(vSheetMonth, nRow, 12, RGBToInt(240, 230, 140));

		ProgressBar1->Max = vSumClasses.size();
		ProgressBar1->Min = 0;
		for (unsigned int i = 0; i < vSumClasses.size(); i++) {
			nRow++;
			ProgressBar1->Position = i;
			nSum += vSumClasses[i].Sum;
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertySet("Value", WideString(vSumClasses[i].Name));
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("Value", WideString(vSumClasses[i].Sum));

			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("NumberFormat", WideString(m_strNumberFormat));

			setBorders(vSheetMonth, nRow, 11);
			setBorders(vSheetMonth, nRow, 12);
		}
		nRow++;
		ProgressBar1->Position = 0;

		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertySet("Value", WideString("Итого:"));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("Value", WideString(nSum));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("NumberFormat", WideString(m_strNumberFormat));

		nRow++;

		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertySet("Value", WideString("Сумма сумм по дням:"));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("Value", WideString(fSumSum));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("NumberFormat", WideString(m_strNumberFormat));
	}

	{
		double nSum = 0;
		int nRow = 2;
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OlePropertySet("Value", WideString("Класс"));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,15).OlePropertySet("Value", WideString("Наименование"));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertySet("Value", WideString("Цена"));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OlePropertySet("Value", WideString("Ссылка"));

		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OlePropertyGet("Font").OlePropertySet("Bold", true);
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,15).OlePropertyGet("Font").OlePropertySet("Bold", true);
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertyGet("Font").OlePropertySet("Bold", true);
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OlePropertyGet("Font").OlePropertySet("Bold", true);

		vSheetMonth.OlePropertyGet("Columns", WideString("N")).OlePropertySet("ColumnWidth", 20);
		vSheetMonth.OlePropertyGet("Columns", WideString("O")).OlePropertySet("ColumnWidth", 50);
		vSheetMonth.OlePropertyGet("Columns", WideString("P")).OlePropertySet("ColumnWidth", 15);
		vSheetMonth.OlePropertyGet("Columns", WideString("Q")).OlePropertySet("ColumnWidth", 50);

		setBorders(vSheetMonth, nRow, 14);
		setBorders(vSheetMonth, nRow, 15);
		setBorders(vSheetMonth, nRow, 16);
		setBorders(vSheetMonth, nRow, 17);

		setColor(vSheetMonth, nRow, 14, RGBToInt(240, 230, 140));
		setColor(vSheetMonth, nRow, 15, RGBToInt(240, 230, 140));
		setColor(vSheetMonth, nRow, 16, RGBToInt(240, 230, 140));
		setColor(vSheetMonth, nRow, 17, RGBToInt(240, 230, 140));

		ProgressBar1->Max = months.size();
		ProgressBar1->Min = 0;
		for (unsigned int i = 0; i < months.size(); i++) {
			nRow++;
			ProgressBar1->Position = i;
			nSum += months[i].Price;

			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OlePropertySet("Value", WideString(months[i].Class));
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,15).OlePropertySet("Value", WideString(months[i].Name));
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertySet("Value", WideString(months[i].Price));
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertySet("NumberFormat", WideString(m_strNumberFormat));

			if (months[i].Price < 0) {
				setColor(vSheetMonth, nRow, 16, RGBToInt(240, 230, 140));
			}


			// TODO: check linkt to classification
			// vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OlePropertySet("Value", WideString(months[i].LinkToClassification.c_str()));

			setBorders(vSheetMonth, nRow, 14);
			setBorders(vSheetMonth, nRow, 15);
			setBorders(vSheetMonth, nRow, 16);
			setBorders(vSheetMonth, nRow, 17);
		}
		nRow++;
		ProgressBar1->Position = 0;

		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OlePropertySet("Value", WideString("Итого:"));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertySet("Value", WideString(nSum));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertySet("NumberFormat", WideString(m_strNumberFormat));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OlePropertySet("NumberFormat", WideString(m_strNumberFormat));
	}

	Log->Lines->Add("Сохраняю файл...");
	try {
		app.OlePropertySet("DisplayAlerts",false);
		excel.OleProcedure("SaveAs", WideString(m_strFileName.c_str()));
		Log->Lines->Add("Данные сохранены!");
	} catch (...) {
		Log->Lines->Add("Ошибка: Пожалуйста закройте все открытые копии файла и повторите операцию");
	}
    ProgressBar1->Position = 0;
	app.OleProcedure("Quit");
}