//--------------------------------------------------------------------------- void __fastcall TFormReportStudsCandRedDiplom::CreateWordDocument(void) { InitReportQuery(); if (ZMySqlQuery->RecordCount==0) return; WordMacros macros; macros.BeginMacros(); macros.InsertLine("ActiveDocument.PageSetup.TopMargin=35"); macros.InsertLine("ActiveDocument.PageSetup.BottomMargin=35"); macros.InsertLine("ActiveDocument.PageSetup.LeftMargin=35"); macros.InsertLine("ActiveDocument.PageSetup.RightMargin=35"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.SelectionFont("Bold=true"); macros.SelectionFont("Size=16"); macros.SelectionText("Список кандидатов на получение красного диплома"); macros.SelectionTypeParagraph(); macros.SelectionFont("Size=12"); macros.SelectionFont("Bold=false"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphLeft"); int CountTables=0; int CountRows; for (int i=0; i<ZMySqlQuery->RecordCount; i++) { ZMySqlQuery->RecNo=i+1; int numgroup=ZMySqlQuery->Fields->FieldByNumber(1)->AsString.ToInt(); // подготавливает запрос на список студенов //InitStudentsForGroup(numgroup); // получает список студентов на красный диплом //CountUsefullStuds=GetCountUsefullStudents(listNumUsefullStuds); //if (CountUsefullStuds==0) continue; std::vector<red_student> redStudents = GetRedStudents(numgroup); if (redStudents.empty()) continue; int CountUsefullStuds = redStudents.size(); macros.SelectionTypeParagraph(); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphLeft"); macros.SelectionText("Группа "); macros.SelectionFont("Bold=true"); macros.SelectionText(WCGetTitleForKeyNum(GROUPS,numgroup)); macros.SelectionFont("Bold=false"); macros.SelectionTypeParagraph(); CountRows=CountUsefullStuds+1; macros.TablesAdd(CountRows,7); CountTables++; macros.TablesColumns(CountTables, 1, "Width = 20"); macros.TablesColumns(CountTables, 2, "Width = 180"); macros.TablesColumns(CountTables, 3, "Width = 60"); macros.TablesColumns(CountTables, 4, "Width = 70"); macros.TablesColumns(CountTables, 5, "Width = 70"); macros.TablesColumns(CountTables, 6, "Width = 70"); macros.TablesColumns(CountTables, 7, "Width = 50"); macros.TablesColumns(CountTables, 1, "Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphRight"); macros.TablesColumns(CountTables, 2, "Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphLeft"); macros.TablesColumns(CountTables, 3, "Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.TablesColumns(CountTables, 4, "Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.TablesColumns(CountTables, 5, "Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.TablesColumns(CountTables, 6, "Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.TablesColumns(CountTables, 7, "Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.SelectionFont("Bold=true"); macros.InsertLine("ActiveDocument.Tables.Item(" + IntToStr(CountTables) + ").Range.Font.Size = 10"); macros.InsertLine("ActiveDocument.Tables.Item(" + IntToStr(CountTables) + ").Rows.Item(1).Range.Font.Bold=true"); // WordDocument->Tables->Item(CountTables)->Range->Select(); macros.TablesCell(CountTables, 1, 1, "Range.Text = \"№\""); macros.TablesCell(CountTables, 1, 1, "Range.Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.TablesCell(CountTables, 1, 2, "Range.Text = \"Фамилия, имя, отчество\""); macros.TablesCell(CountTables, 1, 2, "Range.Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.TablesCell(CountTables, 1, 3, "Range.Text = \"№ зач. книжки\""); macros.TablesCell(CountTables, 1, 3, "Range.Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.TablesCell(CountTables, 1, 4, "Range.Text = \"Кол-во \"\"удовл.\"\" (%)\""); macros.TablesCell(CountTables, 1, 4, "Range.Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.TablesCell(CountTables, 1, 5, "Range.Text = \"Кол-во \"\"хор.\"\" (%)\""); macros.TablesCell(CountTables, 1, 5, "Range.Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.TablesCell(CountTables, 1, 6, "Range.Text = \"Кол-во \"\"отл.\"\" (%)\""); macros.TablesCell(CountTables, 1, 6, "Range.Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.TablesCell(CountTables, 1, 7, "Range.Text = \"Средний балл\""); macros.TablesCell(CountTables, 1, 7, "Range.Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); // проходим по списку на красный диплом for (int j = 0; j < redStudents.size(); ++j) { red_student& redStudent = redStudents[j]; // номер позиции macros.TablesCell(CountTables, j+2,1, "Range.Text= \"" + AnsiString(j+1) + "\""); // фио macros.TablesCell(CountTables, j+2,2, "Range.Text= \"" + redStudent.name + "\""); // номер зачетки macros.TablesCell(CountTables, j+2,3, "Range.Text= \"" + redStudent.znum + "\""); // вычисляет баллы для студента //int countUDOVL,countHOR,countOTL; //double percUDOVL,percHOR,percOTL; //AnsiString AvrgBallStr; //GetBallsCount(countUDOVL,percUDOVL,countHOR,percHOR,countOTL,percOTL,AvrgBallStr,ZMySqlQueryStudsOfGrp->Fields->FieldByNumber(1)->AsString); AnsiString percUDOVLStr = AnsiString(redStudent.perc_ud); AnsiString percHORStr = AnsiString(redStudent.perc_hor); AnsiString percOTLStr = AnsiString(redStudent.perc_otl); char str[10]; sprintf(str,"%4.2lf",percUDOVLStr.ToDouble()); percUDOVLStr = AnsiString(str); sprintf(str,"%4.2lf",percHORStr.ToDouble()); percHORStr = AnsiString(str); sprintf(str,"%4.2lf",percOTLStr.ToDouble()); percOTLStr = AnsiString(str); AnsiString Str=AnsiString(redStudent.count_ud)+" ("+percUDOVLStr+"%)"; macros.TablesCell(CountTables, j+2,4, "Range.Text= \"" + Str + "\""); Str=AnsiString(redStudent.count_hor)+" ("+percHORStr+"%)"; macros.TablesCell(CountTables, j+2,5, "Range.Text= \"" + Str+ "\""); Str=AnsiString(redStudent.count_otl)+" ("+percOTLStr+"%)"; macros.TablesCell(CountTables, j+2,6, "Range.Text= \"" + Str+ "\""); macros.TablesCell(CountTables, j+2,7, "Range.Text= \"" + redStudent.avrBall + "\""); } macros.TablesCell(CountTables, CountRows+1, 1, "Range.Select"); macros.InsertLine("Selection.MoveDown Unit := wdLine"); } //delete listNumUsefullStuds; macros.SelectionParagraphFormat("Alignment = wdAlignParagraphRight"); macros.SelectionFont("Size=8"); macros.SelectionText("(*)В таблицах не учитываются оценки \"\"зачтено\\"", \"\"незачтено\"\" и \"\"неудовлетворительно\"\"."); macros.SelectionTypeParagraph(); macros.SelectionText("(*)Таблицы содержат студентов, имеющих не более одной \"\"удовл\"\" и не менее 75% \"\"отл\"\"."); macros.EndMacros(); macros.RunMacros(); }
//--------------------------------------------------------------------------- void __fastcall TFormReportBUCityMounth::CreateWordDocument(void) { InitReportQuery(); WordMacros macros; macros.BeginMacros(); if (ZMySqlQuery->RecordCount == 0) return; macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.SelectionFont("Size=20"); macros.SelectionFont("Bold=true"); macros.SelectionText("ќтчет по оплате представительств"); macros.SelectionTypeParagraph(); macros.SelectionFont("Size=12"); macros.SelectionFont("Bold=false"); TDateTime DateRep=pFormSelDate->GetSelectedDate(); macros.SelectionText("на "+DateRep.DateString()); macros.SelectionTypeParagraph(); macros.SelectionTypeParagraph(); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphLeft"); macros.SelectionText("ќтчетный период: "); macros.SelectionFont("Bold=true"); macros.SelectionText(GetPeriodStr(DateRep)); macros.SelectionTypeParagraph(); macros.SelectionTypeParagraph(); macros.SelectionFont("Bold=false"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphLeft"); // ‘ормирование таблицы AnsiString Str,Strtmp; int CountTables=0; int CountRows=ZMySqlQuery->RecordCount; macros.TablesAdd(CountRows+1, 3); CountTables++; macros.TablesColumns(CountTables, 1, "Width = 50"); macros.TablesColumns(CountTables, 2, "Width = 300"); macros.TablesColumns(CountTables, 3, "Width = 80"); macros.TablesColumns(CountTables, 1, "Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphLeft"); macros.TablesColumns(CountTables, 2, "Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphLeft"); macros.TablesColumns(CountTables, 3, "Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphRight"); macros.InsertLine("ActiveDocument.Tables.Item(" + IntToStr(CountTables) + ").Range.Font.Size = 10"); macros.InsertLine("ActiveDocument.Tables.Item(" + IntToStr(CountTables) + ").Rows.Item(1).Range.Font.Bold=true"); // WordDocument->Tables->Item(CountTables)->Range->Select(); macros.TablesCell(CountTables, 1, 1, "Range.Text = \"єп/п\""); macros.TablesCell(CountTables, 1, 1, "Range.Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.TablesCell(CountTables, 1, 2, "Range.Text = \"ѕредставительство\""); macros.TablesCell(CountTables, 1, 2, "Range.Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.TablesCell(CountTables, 1, 3, "Range.Text = \"—умма (руб.)\""); macros.TablesCell(CountTables, 1, 3, "Range.Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); AnsiString SummStr; unsigned short year,month,day; DateRep.DecodeDate(&year,&month,&day); long commsumm=0; for (int i=0;i<ZMySqlQuery->RecordCount;i++) { ZMySqlQuery->RecNo=i+1; macros.TablesCell(CountTables, i+2, 1, "Range.Text = \"" + AnsiString(i+1) + "\""); macros.TablesCell(CountTables, i+2, 2, "Range.Text = \"" + ZMySqlQuery->Fields->FieldByNumber(1)->AsString); SummStr=GetSummCity(ZMySqlQuery->Fields->FieldByNumber(2)->AsString,AnsiString(month),AnsiString(year) + "\""); macros.TablesCell(CountTables, i+2, 3, "Range.Text = \"" + SummStr + "\""); commsumm+=SummStr.ToInt(); } macros.TablesCell(CountTables, CountRows+1, 1, "Range.Select"); macros.InsertLine("Selection.MoveDown Unit := wdLine"); macros.SelectionTypeParagraph(); macros.SelectionText("»того: обща¤ сумма зафиксированных выплат со стороны всех представительств составл¤ет "+AnsiString(commsumm)+" рублей."); macros.EndMacros(); macros.RunMacros(); }
//--------------------------------------------------------------------------- void __fastcall TFormReportDocZachislenie::CreateWordDocument(void) { int numspec,numform; InitReportQuery(); WordMacros macros; macros.BeginMacros(); macros.InsertLine("Selection.SetRange Start:=0, End:=0"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphJustify"); macros.SelectionFont("Bold = true"); macros.SelectionText("Слушали: "); macros.SelectionFont("Bold = false"); macros.SelectionText("о зачислении студентами и слушателями ННГАСУ на места с оплатой стоимости обучения на договорной основе."); macros.SelectionTypeParagraph(); macros.SelectionTypeParagraph(); macros.SelectionFont("Bold = true"); macros.SelectionText("Постановили: "); macros.SelectionFont("Bold = false"); macros.SelectionText("зачислить студентами и слушателями ННГАСУ на места с оплатой стоимости обучения на договорной основе."); macros.SelectionTypeParagraph(); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.SelectionTypeParagraph(); macros.SelectionFont("Bold = false"); macros.SelectionText("Зачислить студентами 1-го курса с 01 сентября 20__ года на места с оплатой стоимости обучения на договорной основе следующих абитуриентов:"); macros.SelectionTypeParagraph(); macros.SelectionFont("Bold = true"); macros.SelectionText(" в институт экономики, управления и права"); macros.SelectionTypeParagraph(); macros.SelectionFont("Bold = false"); if (ZMySqlQuery->RecordCount==0) return; numspec=-1; numform=-1; int CountTables=0; int CountRows; int CountPrevRows=0; int CountPrevPrevRows=0; AnsiString Str,Strtmp; for (int i = 0; i < ZMySqlQuery->RecordCount; i++) { ZMySqlQuery->RecNo = i+1; if ( numspec!=ZMySqlQuery->Fields->FieldByNumber(4)->AsString.ToInt() || numform!=ZMySqlQuery->Fields->FieldByNumber(5)->AsString.ToInt() ) { numspec=ZMySqlQuery->Fields->FieldByNumber(4)->AsString.ToInt(); numform=ZMySqlQuery->Fields->FieldByNumber(5)->AsString.ToInt(); macros.SelectionTypeParagraph(); macros.SelectionTypeParagraph(); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter"); macros.SelectionText("на 1 курс по специальности \""); macros.SelectionFont("Bold = true"); macros.SelectionText(WCGetTitleForKeyNum(SPECS,numspec)); macros.SelectionText("\""); macros.SelectionFont("Bold = false"); macros.SelectionText(", с формой обучения - "); macros.SelectionText(WCGetTitleForKeyNum(EDUFORMS,numform)); macros.SelectionTypeParagraph(); macros.SelectionTypeParagraph(); CountRows=0; for (int j=i;j<ZMySqlQuery->RecordCount;j++) { ZMySqlQuery->RecNo=j+1; if (numspec!=ZMySqlQuery->Fields->FieldByNumber(4)->AsString.ToInt() || numform!=ZMySqlQuery->Fields->FieldByNumber(5)->AsString.ToInt()) break; CountRows++; } ZMySqlQuery->RecNo=i+1; macros.TablesAdd(CountRows, 6); macros.TableStyle(WordMacros::StyleNone); CountTables++; macros.TablesColumns(CountTables, 1, "Width = 30"); macros.TablesColumns(CountTables, 2, "Width = 90"); macros.TablesColumns(CountTables, 3, "Width = 80"); macros.TablesColumns(CountTables, 4, "Width = 90"); macros.TablesColumns(CountTables, 5, "Width = 100"); macros.TablesColumns(CountTables, 6, "Width = 50"); macros.TablesColumns(CountTables, 1, "Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphRight"); macros.TablesColumns(CountTables, 2, "Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphLeft"); macros.TablesColumns(CountTables, 3, "Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphLeft"); macros.TablesColumns(CountTables, 4, "Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphLeft"); macros.TablesColumns(CountTables, 5, "Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphRight"); macros.TablesColumns(CountTables, 6, "Select"); macros.SelectionParagraphFormat("Alignment = wdAlignParagraphLeft"); macros.InsertLine("ActiveDocument.Tables.Item(" + IntToStr(CountTables) + ").Range.Font.Size = 10"); CountPrevPrevRows=CountPrevRows; CountPrevRows+=CountRows; } macros.TablesCell(CountTables, i+1-CountPrevPrevRows, 1, "Range.Text = \"" + AnsiString(i+1-CountPrevPrevRows) + "\""); macros.TablesCell(CountTables, i+1-CountPrevPrevRows, 2, "Range.Text = \"" + ZMySqlQuery->Fields->FieldByNumber(1)->AsString + "\""); macros.TablesCell(CountTables, i+1-CountPrevPrevRows, 3, "Range.Text = \"" + ZMySqlQuery->Fields->FieldByNumber(2)->AsString + "\""); macros.TablesCell(CountTables, i+1-CountPrevPrevRows, 4, "Range.Text = \"" + ZMySqlQuery->Fields->FieldByNumber(3)->AsString + "\""); Str=WCGetTitleForKeyNum(DOGSHIFRS,ZMySqlQuery->Fields->FieldByNumber(6)->AsString.ToInt())+"-"; Str+=WCGetTitleForKeyNum(DOGYEARS,ZMySqlQuery->Fields->FieldByNumber(8)->AsString.ToInt()); Strtmp=WCGetTitleForKeyNum(DOGFASTS,ZMySqlQuery->Fields->FieldByNumber(9)->AsString.ToInt()); if (!Strtmp.IsEmpty()) Str+="-"+Strtmp; Str+=" -"; macros.TablesCell(CountTables, i+1-CountPrevPrevRows, 5, "Range.Text = \"" + Str + "\""); macros.TablesCell(CountTables, i+1-CountPrevPrevRows, 6, "Range.Text = \"" + ZMySqlQuery->Fields->FieldByNumber(7)->AsString + "\""); if (i+1 == CountPrevRows) { macros.TablesCell(CountTables, CountRows, 1, "Range.Select"); macros.InsertLine("Selection.MoveDown Unit := wdLine, Count := 2"); } } macros.SelectionParagraphFormat("Alignment = wdAlignParagraphLeft"); macros.SelectionTypeParagraph(); macros.SelectionTypeParagraph(); macros.SelectionTypeParagraph(); macros.SelectionTypeParagraph(); macros.SelectionText("Председатель приемной комиссии"); macros.SelectionTypeParagraph(); macros.SelectionText("ректор, академик Е.В. Копосов"); macros.SelectionTypeParagraph(); macros.SelectionTypeParagraph(); macros.SelectionTypeParagraph(); macros.SelectionText("Ответственный секретарь"); macros.SelectionTypeParagraph(); macros.SelectionText("приемной комиссии, доцент Н.Д. Жилина"); macros.InsertLine("ActiveWindow.ActivePane.VerticalPercentScrolled = 0"); macros.EndMacros(); macros.RunMacros(); }