// Test variantini tayyorlash
try
try
W:=CreateOleObject('Word.Application');
//W.visible:=true;
For i:=1 to n do
begin
W.Documents.Open(FileName:=(FindComponent('F'+IntToStr(i))
As TEdit).Text,ReadOnly:=true);
D[i]:=W.ActiveDocument;
DUT[i]:=StrToInt((FindComponent('UT'+IntToStr(i)) As TEdit).Text);
DT[i]:=(FindComponent('T'+IntToStr(i)) As TSpinEdit).Value;
end;
W.Documents.Add;
Kalit:=W.ActiveDocument;
Kalit.PageSetup.Orientation := 1;
Kalit.PageSetup.TopMargin := 28;
Kalit.PageSetup.BottomMargin :=28;
Kalit.PageSetup.LeftMargin :=28;
Kalit.PageSetup.RightMargin := 28;
Kalit.Range.InsertBefore(' Testlarning kalitli javob fayli ');
MyRange:=Kalit.Range(Kalit.Range.End-1,Kalit.Range.End-1);
Kalit.Tables.Add(
Range:=MyRange,
NumRows:=TestCount.Value+1,
NumColumns:=VariantCount.Value+1);
Kalit.Range.InsertAfter(' ');
Kalit.Tables.item(1).Range.Font.Size := 12;
Kalit.Tables.item(1).Range.Font.Name := 'Times New Roman';
Kalit.Tables.item(1).Columns.Item(1).Width:=56;
Kalit.Tables.item(1).AutoFitBehavior(2);
Kalit.Tables.item(1).Borders.Enable:=true;
Kalit.Tables.item(1).Cell(1, 1).Range.Text:='Test \ variant';
For i:=2 to TestCount.Value+1 do
Kalit.Tables.item(1).Cell(i, 1).Range.Text:=IntToStr(i-1);
Kalit.Tables.item(1).Rows.Item(1).Range.Orientation:= wdTextOrientationUpward;
For i:=2 to VariantCount.Value+1 do
begin
//Kalit.Tables.item(1).Cell(1, i).Range.Orientation:= wdTextOrientationUpward;
Kalit.Tables.item(1).Cell(1, i).Range.Text:=IntToStr(i-1);
end;
Kalit.Tables.item(1).Cell(1, 1).Range.Orientation:= wdTextOrientationHorizontal;
if FileExists(Path.Text+'\Kalit.doc') then
DeleteFile(Path.Text+'\Kalit.doc');
Kalit.SaveAs(Path.Text+'\Kalit.doc');
For i:=1 to VariantCount.Value do // varian sonicha
begin
W.Documents.Add;
D2:=W.ActiveDocument;
D2.PageSetup.Orientation := 0;
D2.PageSetup.TopMargin := 28;
D2.PageSetup.BottomMargin :=28;
D2.PageSetup.LeftMargin :=56;
D2.PageSetup.RightMargin := 28;
D2.Range.InsertBefore(' Test variant № '+IntToStr(i));
D2.Range.InsertParagraphAfter;
D2.Range.InsertAfter(' ');
For j:=0 to Memo1.Lines.Count-1 do
begin
D2.Range.InsertParagraphAfter;
D2.Range.InsertAfter(Memo1.Lines[j]);
end;
D2.Range.InsertParagraphAfter;
D2.Range.InsertAfter(' ');
For j:=0 to Memo2.Lines.Count-1 do
begin
D2.Range.InsertParagraphAfter;
D2.Range.InsertAfter(Memo2.Lines[j]);
//D2.Range.ParagraphFormat.Alignment:=1;
end;
For j:=3+Memo1.Lines.Count to D2.Range.Paragraphs.Count do
D2.Paragraphs.Item(j).Range.ParagraphFormat.Alignment:=1;
D2.Range.InsertParagraphAfter;
D2.Range.InsertAfter(' ');
MyRange:=D2.Range(D2.Range.End-1,D2.Range.End-1);
D2.Tables.Add(
Range:=MyRange,
NumRows:=5*TestCount.Value,
NumColumns:=1);
D2.Range.InsertAfter(' ');
D2.Tables.item(1).Range.Font.Size := 12;
D2.Tables.item(1).Range.Font.Name := 'Times New Roman';
D2.Tables.item(1).AutoFitBehavior(2);
D2.Tables.item(1).Borders.Enable:=true;
// Test yozish
Cur:=1; z:=1;
For j:=1 to TestFaylCount.Value do // test faylicha
begin
For x:=1 to DT[j] do // fayldan nechta test olish
begin
b:=RandomRange(1,DUT[j]);
D[j].Activate;
D[j].Tables.item(b).Cell(1, 1).Range.Copy;
D2.Activate;
D2.Tables.item(1).Cell(Cur, 1).Select;
W.Selection.Paste;
W.Selection.Range.InsertBefore( IntToStr(z)+'. ');
D2.Tables.item(1).Cell(Cur, 1).Range.Font.Bold:=true;
s:=Random(23);
For y:=1 to 4 do
begin
D[j].Activate;
D[j].Tables.item(b).Cell(y+1, 1).Range.Copy;
D2.Activate;
D2.Tables.item(1).Cell(Cur+test[s].j[y], 1).Select;
W.Selection.Paste;
W.Selection.Range.InsertBefore(Chr(64+test[s].j[y])+ ') ');
end;
Kalit.Tables.item(1).Cell(z+1, i+1).Range.Text:=Chr(64+test[s].j[1]);
inc(Cur,5);
inc(z);
end;
end;
// Test yozish
D2.Tables.item(1).Range.Font.Size := 12;
D2.Tables.item(1).Range.Font.Name := 'Times New Roman';
D2.Tables.item(1).select;
W.Selection.Rows.ConvertToText(Separator:=wdSeparateByParagraphs,
NestedTables:=True) ;
W.Selection.ParagraphFormat.SpaceBefore := 0;
W.Selection.ParagraphFormat.SpaceBeforeAuto := False;
W.Selection.ParagraphFormat.SpaceAfter := 0;
W.Selection.ParagraphFormat.SpaceAfterAuto := False;
W.Selection.ParagraphFormat.LineSpacingRule := wdLineSpaceSingle;
if FileExists(Path.Text+'\'+IntToStr(i)) then
DeleteFile(Path.Text+'\'+IntToStr(i));
D2.SaveAs(Path.Text+'\'+IntToStr(i));
D2.Close(false);
end;
For j:=1 to TestFaylCount.Value do
D[j].Close(False);
Kalit.Close(true);
except
ShowMessage('Fayl bilan ishlashga xatolik');
end;
finally
W.Quit;
W:=UnAssigned;
end;
ShowMessage(' Test variantlari ko`rsatilgan'+#10+
Path.text+#10+
'Katalogida hosil bo`ldi.Omad!!! ');
|