示例#1
0
 static void table_text(WordMacros& macros, bool secondTable, int row, int col, string_t text) { 
   if (secondTable)
     macros.CellCell(2, 2, 7, row, col, "Select");
   else
     macros.CellCell(2, 3, 2, row, col, "Select");
   macros.SelectionText(text); 
 }
示例#2
0
//---------------------------------------------------------------------------
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();
}
示例#3
0
//-------------------------------------------------------------------------
void ReportDiplom::Run(int grpId, int studentId)
{
  r::PrivateData privData;
  r::GetPrivateData(privData, studentId);
  DirectData dirData;
  GetDirectData(dirData, privData);
  std::vector<Discip> cursDiscip;
  std::vector<Discip> commonDiscip;
  std::vector<Discip> specDiscip;
  bool useZe = privData.specOrProfilTag.startsWith("бак") || privData.specOrProfilTag == "маг";    // так же для расчета объема программы
  bool anotherEnd = privData.specOrProfilTag.empty() || privData.specOrProfilTag == "бак1";
  GetDiscipInfo(studentId, cursDiscip, commonDiscip, specDiscip, privData.lang, privData.vkrTitle, useZe, anotherEnd);

  WordMacros macros;
  macros.BeginMacros();

  // ФИО
  macros.Cell(1, 3, 7, "Range.Select");
  macros.SelectionText(privData.secondName);
  macros.Cell(1, 4, 7, "Range.Select");
  macros.SelectionText(privData.firstName);
  macros.Cell(1, 5, 7, "Range.Select");
  macros.SelectionText(privData.thirdName);

  // дата рождения
  macros.Cell(1, 6, 8, "Range.Select");
  macros.SelectionText(r::to_str_date(privData.bornDate, "года"));

  // аттестат
  macros.Cell(1, 8, 6, "Range.Select");
  macros.SelectionText(privData.prevDoc.toUpperFirst() + " " + privData.prevDocYear + " год");

  // номер регистрации
  macros.Cell(1, 13, 5, "Range.Select");
  macros.SelectionText(privData.regNum);

  // дата выдачи
  macros.Cell(1, 15, 7, "Range.Select");
  macros.SelectionText(r::to_str_date(privData.dataVidachi, "года"));  

  // специалиста (специалиста с отличием, бакалавра, бакалавра с отличием)
  macros.Cell(1, 9, 4, "Range.Select");
  macros.SelectionText(dirData.title1);

  // по специальности, по направлению
  macros.Cell(1, 11, 9, "Range.Select");
  macros.SelectionText(dirData.title2);

  // сколько обучался
  macros.Cell(1, 15, 9, "Range.Select");
  macros.SelectionText(dirData.title3);

  // дополнительная информация
  macros.Cell(1, 12, 3, "Range.Select");
  macros.SelectionText(dirData.bottomInfo);

  // курсовые работы
  for (int i = 0; i < (int)cursDiscip.size(); ++i)
  {
     macros.CellCell(1, 3, 2, i + 1, 1, "Select");
     macros.SelectionText(toQuate(cursDiscip[i].title));
     macros.CellCell(1, 3, 2, i + 1, 2, "Select");
     macros.SelectionText(cursDiscip[i].ocenka);
  }
  
  struct local
  {
    static void table_text(WordMacros& macros, bool secondTable, int row, int col, string_t text) { 
      if (secondTable)
        macros.CellCell(2, 2, 7, row, col, "Select");
      else
        macros.CellCell(2, 3, 2, row, col, "Select");
      macros.SelectionText(text); 
    }
  };

  // обычные дисциплины на первой таблице
  int table1RowCount = 56;  // всего осталось строк в первой таблице
  int usedDiscip = 0;       // сколько на самом деле добавили дисциплин в первую таблицу
  for (int i = 0; i < (int)commonDiscip.size() && table1RowCount > 0; ++i)
  {
    table1RowCount -= PrepareDiscipTitle(commonDiscip[i].title, 63);
    if (table1RowCount < 0) // если строка не уберется в конце таблицы, то сразу нечего продолжать
      break;

    usedDiscip++;
    local::table_text(macros, false, i+1, 1, toQuate(commonDiscip[i].title));
    local::table_text(macros, false, i+1, 2, commonDiscip[i].period);
    local::table_text(macros, false, i+1, 3, commonDiscip[i].ocenka);
  }
  
  int table2CurRow = 1;
  bool need_second_table = usedDiscip < (int)commonDiscip.size();
  // обычные дисциплины во второй таблице если не хватило места на первой
  if (need_second_table)
    for (int i = usedDiscip; i < (int)commonDiscip.size(); ++i)
    {
      local::table_text(macros, true, table2CurRow, 1, toQuate(commonDiscip[i].title));
      local::table_text(macros, true, table2CurRow, 2, commonDiscip[i].period);
      local::table_text(macros, true, table2CurRow, 3, commonDiscip[i].ocenka);
      ++table2CurRow;
    }
  
  // остальные данные могут или убраться на первой таблице или надо перенести на вторую
  if (!need_second_table)
    if (table1RowCount <= (int)specDiscip.size())
      need_second_table = true;

  int rowPos = need_second_table ? table2CurRow : usedDiscip + 1;
  for (int i = 0; i < (int)specDiscip.size(); ++i)
  {
    local::table_text(macros, need_second_table, rowPos+i, 1, toQuate(specDiscip[i].title));
    local::table_text(macros, need_second_table, rowPos+i, 2, specDiscip[i].period);
    local::table_text(macros, need_second_table, rowPos+i, 3, specDiscip[i].ocenka);
  }

  macros.EndMacros();
  macros.RunMacros(theApp.GetModuleDir() + "diplom-2014.dot");
}
示例#4
0
//---------------------------------------------------------------------------
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();
}
示例#5
0
//-------------------------------------------------------------------------
void ReportDiplom2015::Run(int grpId, int studentId)
{
  WordMacros macros;
  macros.BeginMacros();

  ReportDiplim2015Data data = GetData(grpId, studentId);

  macros.Replace("$FIO_1$",        data.fio1);
  macros.Replace("$FIO_2$",        data.fio2);
  macros.Replace("$SPEC$",         data.spec);
  macros.Replace("$KVALIF$",       data.kvalif);
  macros.Replace("$GAK_NUM$",      data.gakNum);
  macros.Replace("$D1$",           data.kvalifDay);
  macros.Replace("$D2$",           data.kvalifMonth);
  macros.Replace("$D3$",           data.kvalifYear);
  macros.Replace("$REG_NUM$",      data.regNum);
  macros.Replace("$DIPLOM_DATE$", data.diplomDate);

  macros.EndMacros();
  macros.RunMacros(theApp.GetModuleDir() + "diplom-2015.dot");
}
示例#6
0
//---------------------------------------------------------------------------
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();

}
示例#7
0
//---------------------------------------------------------------------------
void __fastcall TFormReportBULast2::CreateWordDocument(long rows_count)
{
    WordMacros macros;
    macros.BeginMacros();

    macros.InsertLine("ActiveDocument.PageSetup.Orientation = wdOrientLandscape");
    macros.InsertLine("ActiveDocument.PageSetup.TopMargin = 25");
    macros.InsertLine("ActiveDocument.PageSetup.BottomMargin = 25");
    macros.InsertLine("ActiveDocument.PageSetup.LeftMargin = 25");
    macros.InsertLine("ActiveDocument.PageSetup.RightMargin = 25");

    macros.SelectionParagraphFormat("Alignment = wdAlignParagraphCenter");
    macros.SelectionFont("Size=20");
    macros.SelectionFont("Bold=true");
    macros.SelectionText("2010/2011 гг.");
    macros.SelectionFont("Size=10");
    macros.SelectionFont("Bold=false");

    macros.TablesAdd(2 + rows_count, 7);

    // размеры
    macros.TablesColumns(1, 1, "Width = 200");
    macros.TablesColumns(1, 2, "Width = 70");
    macros.TablesColumns(1, 3, "Width = 100");
    macros.TablesColumns(1, 4, "Width = 100");
    macros.TablesColumns(1, 5, "Width = 100");
    macros.TablesColumns(1, 6, "Width = 100");
    macros.TablesColumns(1, 7, "Width = 100");

    macros.InsertLine("ActiveDocument.Tables.Item(1).Range.Font.Size = 9");
    macros.InsertLine("ActiveDocument.Tables.Item(1).Rows.Item(1).Range.Font.Bold = true");
    macros.InsertLine("ActiveDocument.Tables.Item(1).Rows.Item(2).Range.Font.Bold = true");

    macros.InsertLine("ActiveDocument.Tables.Item(1).Cell(1,1).Range.Select");
    macros.SelectionParagraphFormat("Alignment=wdAlignParagraphCenter");
    macros.InsertLine("Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend");
    macros.InsertLine("Selection.Cells.Merge");
    macros.TablesCell(1, 1, 1, "VerticalAlignment=wdCellAlignVerticalCenter");
    macros.TablesCell(1, 1, 1, "Range.Text = \"Ф.И.О.\"");

    macros.InsertLine("ActiveDocument.Tables.Item(1).Cell(1,2).Range.Select");
    macros.SelectionParagraphFormat("Alignment=wdAlignParagraphCenter");
    macros.InsertLine("Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend");
    macros.InsertLine("Selection.Cells.Merge");
    macros.TablesCell(1, 1, 2, "VerticalAlignment=wdCellAlignVerticalCenter");
    macros.TablesCell(1, 1, 2, "Range.Text = \"Группа\"");

    macros.InsertLine("ActiveDocument.Tables.Item(1).Cell(1,3).Range.Select");
    macros.SelectionParagraphFormat("Alignment=wdAlignParagraphCenter");
    macros.InsertLine("Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend");
    macros.InsertLine("Selection.Cells.Merge");
    macros.TablesCell(1, 1, 3, "VerticalAlignment=wdCellAlignVerticalCenter");
    macros.TablesCell(1, 1, 3, "Range.Text = \"Долг за предыдущ. период на 01.09.2010\"");

    macros.InsertLine("ActiveDocument.Tables.Item(1).Cell(1,4).Range.Select");
    macros.SelectionParagraphFormat("Alignment=wdAlignParagraphCenter");
    macros.InsertLine("Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend");
    macros.InsertLine("Selection.Cells.Merge");
    macros.TablesCell(1, 1, 4, "VerticalAlignment=wdCellAlignVerticalCenter");
    macros.TablesCell(1, 1, 4, "Range.Text = \"Стоимость обучения 2010/2011\"");

    macros.InsertLine("ActiveDocument.Tables.Item(1).Cell(1,5).Range.Select");
    macros.SelectionParagraphFormat("Alignment=wdAlignParagraphCenter");
    macros.InsertLine("Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend");
    macros.InsertLine("Selection.Cells.Merge");
    macros.TablesCell(1, 1, 5, "VerticalAlignment=wdCellAlignVerticalCenter");
    macros.TablesCell(1, 1, 5, "Range.Text = \"Оплачено\"");

    macros.InsertLine("ActiveDocument.Tables.Item(1).Cell(2,5).Range.Select");
    macros.SelectionParagraphFormat("Alignment=wdAlignParagraphCenter");
    macros.TablesCell(1, 2, 5, "VerticalAlignment=wdCellAlignVerticalCenter");
    macros.TablesCell(1, 2, 5, "Range.Text = \"на 01.09.2010 за 2010/2011\"");

    macros.InsertLine("ActiveDocument.Tables.Item(1).Cell(2,6).Range.Select");
    macros.SelectionParagraphFormat("Alignment=wdAlignParagraphCenter");
    macros.TablesCell(1, 2, 6, "VerticalAlignment=wdCellAlignVerticalCenter");
    macros.TablesCell(1, 2, 6, "Range.Text = \"на 01.09.2010 за 2010/2011\"");

    macros.InsertLine("ActiveDocument.Tables.Item(1).Cell(2,7).Range.Select");
    macros.SelectionParagraphFormat("Alignment=wdAlignParagraphCenter");
    macros.TablesCell(1, 2, 7, "VerticalAlignment=wdCellAlignVerticalCenter");
    macros.TablesCell(1, 2, 7, "Range.Text = \"на 01.09.2010 за 2010/2011\"");

    AnsiString text;
    text += "Ф.И.О\tГруппа\tДолг за предыдущ.\tСтоимость\tОплачено\tОплачено\tДолг на\n";
    text += "\t\t период на\tобучения\tна 01.09."+firstyear+"\tна 01.12."+firstyear+"\t01.09."+firstyear+"\n";
    text += "\t\t01.09."+firstyear+"\t"+firstyear+"/"+secondyear+" г.\tза "+firstyear+"/"+secondyear+ " г.\tза "+firstyear+"/"+secondyear+" г.\n\n";



    mysql_query(mysql, " SELECT CONCAT_WS(' ', s.secondname, s.firstname, s.thirdname) as name, v.title, f.pre_dolg, f.plan, f.pay_09, f.pay_12, f.dolg_09 "
                       " FROM full_table as f, students as s, voc as v "
                       " WHERE s.id = f.idstud AND v.vkey='grp' AND v.num = f.grpid AND v.deleted = 0 "
                       " ORDER BY v.title, name ");
  //  Application->MessageBox(AnsiString(rows_count).c_str(),"Ошибка.",MB_OK|MB_ICONEXCLAMATION);

    MYSQL_RES* result;
    MYSQL_ROW  row;
    int        cur_row = 3;
    if (result = mysql_store_result(mysql))
      while (row = mysql_fetch_row(result))
      {
        /*macros.InsertLine("ActiveDocument.Tables.Item(1).Cell("+IntToStr(cur_row)+",1).Range.Text= \"" + AnsiString(row[0]) + "\"");
        macros.InsertLine("ActiveDocument.Tables.Item(1).Cell("+IntToStr(cur_row)+",2).Range.Text= \"" + AnsiString(row[1]) + "\"");
        macros.InsertLine("ActiveDocument.Tables.Item(1).Cell("+IntToStr(cur_row)+",3).Range.Text= \"" + AnsiString(row[2]) + "\"");
        macros.InsertLine("ActiveDocument.Tables.Item(1).Cell("+IntToStr(cur_row)+",4).Range.Text= \"" + AnsiString(row[3]) + "\"");
        macros.InsertLine("ActiveDocument.Tables.Item(1).Cell("+IntToStr(cur_row)+",5).Range.Text= \"" + AnsiString(row[4]) + "\"");
        macros.InsertLine("ActiveDocument.Tables.Item(1).Cell("+IntToStr(cur_row)+",6).Range.Text= \"" + AnsiString(row[5]) + "\"");
        macros.InsertLine("ActiveDocument.Tables.Item(1).Cell("+IntToStr(cur_row)+",7).Range.Text= \"" + AnsiString(row[6]) + "\"");
        */
        text += AnsiString(row[0]) + "\t" + AnsiString(row[1]) + "\t";
        text += AnsiString(row[2]) + "\t" + AnsiString(row[3]) + "\t";
        text += AnsiString(row[4]) + "\t" + AnsiString(row[5]) + "\t";
        text += AnsiString(row[6]) + "\n";
        ++cur_row;

      }
    mysql_free_result(result);

    mysql_query(mysql, " SELECT SUM(f.pre_dolg), SUM(f.plan), SUM(f.pay_09), SUM(f.pay_12), SUM(f.dolg_09) "
                       " FROM full_table as f");
    if (result = mysql_store_result(mysql))
      if (row = mysql_fetch_row(result))
      {
         text += "Итого:\t\t";
         text += AnsiString(row[0]) + "\t" + AnsiString(row[1]) + "\t";
         text += AnsiString(row[2]) + "\t" + AnsiString(row[3]) + "\t";
         text += AnsiString(row[4]) + "\n";
      }
    mysql_free_result(result);

    macros.EndMacros();
    // macros.RunMacros();

    HANDLE  hfile = CreateFile("Account.prn", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

    DWORD dwBytesWritten;
    WriteFile(hfile, text.c_str(), text.Length(),&dwBytesWritten,NULL);
    CloseHandle(hfile);

    AnsiString info = "Данные по оплате сохранены в файл 'Account.prn'.\n"
                      "Файл требуется открыть при помощи MS Excel.\n"
                      "При открытии запустится мастер импорта, в котором надо нажать 'Готово'.";
    Application->MessageBox(info.c_str(),"Информация",MB_OK|MB_ICONINFORMATION);

}