2.4 Протокол тестирования программного продукта
Данный программный продукт удовлетворяет всем функциональным требованиям, имеет дружественный интерфейс, легок и понятен в пользовании, максимально исключает появление системных ошибок.
Таблица 2.4.1 – Сообщения пользователю
Сообщение |
Причина |
Действия |
1 |
2 |
3 |
«Выберите пользователя!» |
Не выбран пользователь |
Нажать кнопку «ОК» и выбрать пользователя |
«Введите пароль!» |
Не введен пароль |
Нажать кнопку «ОК» и ввести пароль |
«Неверный пароль!» |
Пароль введен не верноподключение к базе данных |
Нажать кнопку «ОК» и повторить набор пароля |
При тестировании программного продукта на данных контрольного примера обработка данных (т.е. изменение, удаление, вывода выходных документов) осуществляется корректно.
Результаты тестирования полностью совпадают с ожидаемыми. Результаты корректных выходных документов представлены в приложении Е.
2.5 Руководство пользователя
Для запуска программы необходимо запустить приложение Project1.exe. Во избежание неполадок не следует удалять, переименовывать и перемещать файлы из рабочего каталога программы.
Первая форма – форма входа в систему (рисунок 2.5.1).
Рисунок 2.5.1 - Вход в систему
При нажатии на кнопку «О системе» открывается одноименное окно (рисунок 2.5.2).
Рисунок 2.5.2 - Окно о системе
Для закрытия окна нужно нажать кнопку «Выход». Снова появляется форма входа в систему. Для того чтобы войти в систему, необходимо нажать одноименную кнопку. Появляется окно авторизации в системе (рисунок 2.5.3).
Рисунок 2.5.3 - Авторизация в системе
Существует три типа учетных записей: мастер, менеджер и администратор системы. Войдем в систему через администратора. Перед нами появляется главное окно системы (рисунок 2.5.4).
Рисунок 2.5.4 - Главное окно системы
На главном окне расположены вкладки «Пользователи», «Мастера», «Клиенты», «О системе», «Выход».
Пункт «Пользователи» на главном окне системы (рисунок 2.5.4) открывает одноименное окно. В данном окне имеется возможность добавления, редактирования и удаления данных(рисунок 2.5.5).
Рисунок 2.5.5 - Окно "Пользователи"
Пункт «Выход» соответственно производит выход на главное окно системы.
Вкладка «Мастера» на главном окне системы (рисунок 2.5.4). В окне «Мастера» возможны добавление, редактирование, удаление иинформации по мастерам (рисунок 2.5.6).
Рисунок 2.5.6 - Окно "Мастера"
Вкладка «Клиенты» на главном окне системы (рисунок 2.5.4) вызывает одноименное окно (рисунок 2.5.7) .
Рисунок 2.5.7 – Окно "Клиенты"
В данном окне возможно формирование отчета.
Вкладка «О системе» на главном окне системы (рисунок 2.5.4) соотвествует окну «О системе» (рисунок 2.5.2).
ЗАКЛЮЧЕНИЕ
В процессе выполнения дипломного проекта были разработаны структура и алгоритм работы приложения студии художественной татуировки, разработана постановка задачи, описана входная и выходная информация, составлен контрольный пример, сформулированы требования к продукту. Результатом работы стало создание программного продукта, облегчающего работу студии хулжественной татуировки.
Программное обеспечение написано на языке Object Pascal с использованием среды разработки Delphi 7. Результаты выводятся в MS Word. Код программы представлен в приложении А.
Были проведены опытная эксплуатация и отладочное тестирование программного обеспечения. По результатам отладочного тестирования были устранены некоторые недостатки. После этого были написаны руководство пользователей.
Приложение А. Форма выходного документа
-
id
Мастер
Клиент
Дата/Время
1
Исхакова
Петров
24.02.2017 10:00:00
Приложение Б. Исходный код программы
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit3, Unit8;
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Form3.Show;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
Form8.Show;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
close;
end;
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, Unit2, DBCtrls;
type
TForm3 = class(TForm)
LabeledEdit2: TLabeledEdit;
BitBtn1: TBitBtn;
DBLookupComboBox1: TDBLookupComboBox;
Label1: TLabel;
procedure BitBtn1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses Unit4;
{$R *.dfm}
procedure TForm3.BitBtn1Click(Sender: TObject);
begin
if DBLookupComboBox1.Text='' then ShowMessage('Выберите пользователя.')
else if LabeledEdit2.Text='' then begin
ShowMessage('Введите пароль!');
LabeledEdit2.SetFocus;
end
else if LabeledEdit2.Text=DataModule2.Users.FieldByName('Пароль').AsString then begin
Form4.Show;
Hide;
end else begin
ShowMessage('Неверный пароль!');
end;
end;
procedure TForm3.FormShow(Sender: TObject);
begin
LabeledEdit2.Clear;
end;
end.
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Unit2, DB, Grids, DBGrids, Menus, ExtCtrls, DBCtrls, StdCtrls,
Buttons, MyWord;
type
TForm4 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
N4: TMenuItem;
N5: TMenuItem;
BitBtn1: TBitBtn;
procedure FormShow(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
uses Unit5, Unit6, Unit7, Unit8;
{$R *.dfm}
procedure TForm4.FormShow(Sender: TObject);
begin
if DataModule2.Users.FieldByName('Должность').AsString='Мастер' then begin
N1.Visible:=False;
N2.Visible:=False;
N3.Visible:=False;
end;
begin
if DataModule2.Users.FieldByName('Должность').AsString='Менеджер' then begin
N1.Visible:=False;
end;
end;
end;
procedure TForm4.N1Click(Sender: TObject);
begin
Form5.Show;
end;
procedure TForm4.N2Click(Sender: TObject);
begin
Form6.Show;
end;
procedure TForm4.N3Click(Sender: TObject);
begin
Form7.Show;
end;
procedure TForm4.N4Click(Sender: TObject);
begin
Form8.Show;
end;
procedure TForm4.N5Click(Sender: TObject);
begin
close;
end;
procedure TForm4.BitBtn1Click(Sender: TObject);
var
table:integer;
begin
if CreateWord then begin
VisibleWord(false);
AddDoc;
DataModule2.Works.DisableControls;
WordTableAddFromDBGrid(DBGrid1,true,table);
VisibleWord(true);
DataModule2.Works.EnableControls;
end;
end;
end.
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Unit2, Menus, ExtCtrls, DBCtrls, Grids, DBGrids;
type
TForm5 = class(TForm)
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
implementation
uses Unit7, Unit8;
{$R *.dfm}
procedure TForm5.N1Click(Sender: TObject);
begin
Form8.Show;
end;
procedure TForm5.N2Click(Sender: TObject);
begin
close;
end;
end.
unit Unit6;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Unit2, Grids, DBGrids, ExtCtrls, DBCtrls, Menus;
type
TForm6 = class(TForm)
MainMenu1: TMainMenu;
N3: TMenuItem;
N4: TMenuItem;
DBNavigator1: TDBNavigator;
DBGrid1: TDBGrid;
procedure N3Click(Sender: TObject);
procedure N4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form6: TForm6;
implementation
uses Unit8;
{$R *.dfm}
procedure TForm6.N3Click(Sender: TObject);
begin
Form8.Show;
end;
procedure TForm6.N4Click(Sender: TObject);
begin
close;
end;
end.
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Unit2, ExtCtrls, DBCtrls, Grids, DBGrids, Menus;
type
TForm7 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
implementation
uses Unit8;
{$R *.dfm}
procedure TForm7.N1Click(Sender: TObject);
begin
form8.Show;
end;
procedure TForm7.N2Click(Sender: TObject);
begin
close;
end;
end.
unit Unit8;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm8 = class(TForm)
BitBtn1: TBitBtn;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form8: TForm8;
implementation
{$R *.dfm}
procedure TForm8.BitBtn1Click(Sender: TObject);
begin
close;
end;
end.
unit MyWord;
interface
uses Grids,SysUtils,DBGrids;
type
WdFonts=integer;
const
{ wdStyleNormal = $FFFFFFFF;
wdStyleBodyText = $FFFFFFBD;
wdStyleHeading1 = $FFFFFFFE;
wdStyleHeading2 = $FFFFFFFD;
wdStyleHeading3 = $FFFFFFFC; }
wdStyleNormal = -1;
wdStyleBodyText = -1;
wdStyleHeading1 = -2;
wdStyleHeading2 = -3;
wdStyleHeading3 = -4;
type
WdUnits=integer;
const
wdPage =$00000000;
wdCharacter =$00000001;
wdWord = $00000002;
wdSentence = $00000003;
wdParagraph = $00000004;
wdLine = $00000005;
wdStory = $00000006;
wdScreen = $00000007;
wdSection = $00000008;
wdColumn = $00000009;
wdRow = $0000000A;
wdWindow = $0000000B;
wdCell = $0000000C;
wdCharacterFormatting = $0000000D;
wdParagraphFormatting = $0000000E;
wdTable = $0000000F;
wdItem = $00000010;
wdAutoFitFixed =0;
wdAutoFitContent =1;
wdAutoFitWindow =2;
wdAdjustNone=0;
wdOrientPortrait=0;
wdOrientLandScape=1;
wdAlignParagraphCenter=1;
wdAlignParagraphLeft=0;
wdAlignParagraphRight=2;
wdMove=0;
wdExtend=1;
wdBorderTop = $FFFFFFFF;
wdBorderLeft = $FFFFFFFE;
wdBorderBottom = $FFFFFFFD;
wdBorderRight = $FFFFFFFC;
wdBorderHorizontal = $FFFFFFFB;
wdBorderVertical = $FFFFFFFA;
wdLineStyleNone=0;
wdDialogFileSaveAs = $00000054;
wdDialogFileSummaryInfo = $00000056;
wdDialogToolsTemplates = $00000057;
wdDialogFilePrint = $00000058;
wdDialogFilePrintSetup = $00000061;
wdDialogFileFind = $00000063;
wdDialogFormatAddrFonts = $00000067;
wdDialogEditPasteSpecial = $0000006F;
wdDialogEditFind = $00000070;
wdDialogEditReplace = $00000075;
Function CreateWord:boolean;
Function VisibleWord(visible:boolean):boolean;
Function AddDoc:boolean;
Function AddDocFile(FileName:string):boolean;
Function OpenDoc(file_:string):boolean;
Function SaveDocAs(file_:string):boolean;
Function CloseDoc:boolean;
Function CloseWord:boolean;
Function InsertBreak(WdBreakType:WdUnits):boolean;
Function InsertParagraphAfter:boolean;
Function InsertParagraphAfterTable(table:integer):boolean;
Function MoveInDoc(UnitType:WdUnits;Count:integer):boolean;
Function PageCount:integer;
Function WordCount:integer;
Function StartOfDoc:boolean;
Function EndOfDoc:boolean;
Function TypeTextDoc(text_:string):boolean;
Function SetTextToDoc(text_:string ;InsertAfter_:boolean):boolean;
Function GetDocToText(var text:string; wordNum:integer):boolean;
Function FindTextDoc(text_:string):boolean;
Function PasteTextDoc(text_:string):boolean;
Function FindAndPasteTextDoc(findtext_,pastetext_:string):boolean;
Function FindAndInsert(FindText,ReplacementText:string):boolean;
Function DialogWord(Dialog:Wdunits):boolean;
Function SetFont(FontName:WdFonts):boolean;
//Table-------
Function CreateTable(NumRows, NumColumns:integer;var index:integer):boolean;
Procedure GetWordTablesCellValue(Table,Row,Column:integer;var S:string );
Procedure SetWordTablesCellValue(Table,Row,Column:integer;S:string);
procedure GetTableInStringGrid(Table:integer;var StringGrid:TStringGrid);
procedure GetStringGridInTable(StringGrid:TStringGrid;var Table:integer);
procedure GetStringGridInTable2(StringGrid:TStringGrid;var Table:integer;ColArr:array of integer);
procedure WordTableAddFromDBGrid(DBGrid: TDBGrid;CollSize:boolean;var Table:integer);
Function SetSizeTable(Table:integer;RowsHeight, ColumnsWidth:real):boolean;
Function GetSizeTable(Table:integer;var RowsHeight,ColumnsWidth:real):boolean;
Function SetHeightRowTable(Table,Row:integer;RowHeight:real):boolean;
Function GetHeightRowTable(Table,Row:integer;var RowHeight:real):boolean;
Function SetWidthColumnTable(Table,Column:integer;ColumnWidth:real):boolean;
Function GetWidthColumnTable(Table,Column:integer;var ColumnWidth:real):boolean;
Function SetTextToTable(Table:integer;Row,Column:integer;text:string):boolean;
Procedure GetTextFromTable(Table:integer;Row,Column:integer;var text:string);
Function CopyHereRawFromTable(table,Row1,Row2:integer):boolean;
Function SetLineStyleBorderTable(Table:integer;Row,Column,wdBorderType,wdBorderStyle:WdUnits):boolean;
Function SetMergeCellsTable(Table:integer;Row1,Column1,Row2,Column2:integer):boolean;
procedure TableAutoFit(Table:integer);
Procedure MakeNewLineInTable(Table,AfterRow,NewRowCount:integer);
Procedure DeleteRowInTable(Table,Row:integer);
//Table-------
procedure InsertPicture(FileName:string);
implementation
uses ComObj;
var W:variant;
Function CreateWord:boolean;
begin
CreateWord:=true;
try
W:=CreateOleObject('Word.Application');
W.Options.CheckGrammarAsYouType:=False;
W.Options.CheckSpellingAsYouType:=False;
except
CreateWord:=false;
end;
End;
Function VisibleWord(visible:boolean):boolean;
begin
VisibleWord:=true;
try
W.visible:= visible;
except
VisibleWord:=false;
end;
End;
Function AddDoc:boolean;
Var Doc_:variant;
i:integer;
begin
AddDoc:=true;
try
Doc_:=W.Documents;
Doc_.Add;
except
AddDoc:=false;
end;
End;
Function AddDocFile(FileName:string):boolean;
Var Doc_:variant;
begin;
AddDocFile:=true;
try
Doc_:=W.Documents;
Doc_.Add(FileName);
except
AddDocfile:=false;
end;
end;
Function InsertBreak(WdBreakType:WdUnits):boolean;
begin
W.Selection.InsertBreak(WdBreakType);
end;
Function InsertParagraphAfter:boolean;
begin
W.Selection.InsertParagraphAfter;
W.Selection.InsertParagraphAfter;
W.Selection.Move(wdParagraph,1);
end;
Function InsertParagraphAfterTable(table:integer):boolean;
begin
W.Selection.Start:=W.ActiveDocument.Tables.Item(Table).Range.End;
W.Selection.End:=W.ActiveDocument.Tables.Item(Table).Range.End;
W.Selection.InsertParagraphAfter;
end;
Function MoveInDoc(UnitType:WdUnits;Count:integer):boolean;
begin
W.Selection.Move(UnitType,Count);
end;
Function PageCount:integer;
begin
result:=W.ActiveDocument.ComputeStatistics(2);
end;
Function WordCount:integer;
begin
result:=W.ActiveDocument.Words.Count;
end;
Function SetTextToDoc(text_:string ;InsertAfter_:boolean):boolean;
var Rng_:variant;
begin
SetTextToDoc:=true;
try
Rng_:=W.ActiveDocument.Range;
if InsertAfter_ then Rng_.InsertAfter(text_) else Rng_.InsertBefore(text_);
except
SetTextToDoc:=false;
end;
End;
Function GetDocToText(var text:string; wordNum:integer):boolean;
var Rng_:variant;
begin
GetDocToText:=true;
try
text:=W.ActiveDocument.Words.Item(wordNum).Text
except
GetDocToText:=false;
end;
End;
Function SaveDocAs(file_:string):boolean;
begin
SaveDocAs:=true;
try
W.ActiveDocument.SaveAs(file_);
except
SaveDocAs:=false;
end;
End;
Function CloseDoc:boolean;
begin
CloseDoc:=true;
try
W.ActiveDocument.Close;
except
CloseDoc:=false;
end;
End;
Function CloseWord:boolean;
begin
CloseWord:=true;
try
W.Quit;
except
CloseWord:=false;
end;
End;
Function OpenDoc(file_:string):boolean;
Var Doc_:variant;
begin
OpenDoc:=true;
try
Doc_:=W.Documents;
Doc_.Open(file_);
W.ActiveDocument.ShowSpellingErrors:=false;
except
OpenDoc:=false;
end;
End;
Function StartOfDoc:boolean;
begin
StartOfDoc:=true;
try
W.Selection.End:=0;
W.Selection.Start:=0;
except
StartOfDoc:=false;
end;
End;
Function EndOfDoc:boolean;
begin
EndOfDoc:=true;
try
W.Selection.End:=W.ActiveDocument.Characters.Count;
W.Selection.Start:=W.ActiveDocument.Characters.Count;
except
EndOfDoc:=false;
end;
End;
Function FindTextDoc(text_:string):boolean;
begin
FindTextDoc:=true;
Try
W.Selection.Find.Forward:=true;
W.Selection.Find.Text:=text_;
FindTextDoc := W.Selection.Find.Execute;
except
FindTextDoc:=false;
end;
End;
Function PasteTextDoc(text_:string):boolean;
begin
PasteTextDoc:=true;
Try
W.Selection.Delete;
W.Selection.InsertAfter (text_);
except
PasteTextDoc:=false;
end;
End;
Function TypeTextDoc(text_:string):boolean;
begin
TypeTextDoc:=true;
Try
W.Selection.Delete;
W.Selection.TypeText(text_);
except
TypeTextDoc:=false;
end;
End;
Function FindAndPasteTextDoc(findtext_,pastetext_:string):boolean;
begin
FindAndPasteTextDoc:=true;
try
W.Selection.Find.Forward:=true;
W.Selection.Find.Text:= findtext_;
if W.Selection.Find.Execute then begin
W.Selection.Delete;
W.Selection.InsertAfter (pastetext_);
end else FindAndPasteTextDoc:=false;
except
FindAndPasteTextDoc:=false;
end;
End;
Function FindAndInsert(FindText,ReplacementText:string):boolean;
const wdReplaceAll=2;
begin
W. Selection.Find.Text:=FindText;
W.Selection.Find.Replacement.Text:=ReplacementText;
FindAndInsert:=W.Selection.Find.Execute(Replace:=wdReplaceAll);
end;
Function DialogWord(Dialog:Wdunits):boolean;
begin
DialogWord:=true;
try
W.Dialogs.Item(Dialog).Show;
except
DialogWord:=false;
end;
End;
Function SetFont(FontName:WdFonts):boolean;
begin
W.Selection.Style:=(FontName);
end;
Function CreateTable(NumRows, NumColumns:integer;var index:integer):boolean;
var Range:variant;
begin
CreateTable:=true;
try
EndOfDoc;
W.ActiveDocument.Tables.Add(W.Selection.Range, NumRows:=NumRows, NumColumns:=NumColumns);
index:=W.ActiveDocument.Tables.Count;
W.ActiveDocument.Tables.Item(index).Borders.Enable:=true;
W.ActiveDocument.Range.InsertAfter(' ');
except
CreateTable:=false;
end;
End;
Procedure GetWordTablesCellValue(Table,Row,Column:integer;var S:string);
begin
S:=W.ActiveDocument.Tables.Item(Table).Cell(Row,Column).Range.Text;
S:=StringReplace(S, #$D,'',[rfReplaceAll]);
S:=StringReplace(S, #$7,'',[rfReplaceAll]);
end;
Procedure SetWordTablesCellValue(Table,Row,Column:integer;S:string);
begin
W.ActiveDocument.Tables.Item(Table).Cell(Row,Column).Range.Text:=S;
end;
procedure GetTableInStringGrid(Table:integer;var StringGrid:TStringGrid);
var
S:string;
i,j,icols,irows:integer;
begin
try
irows:=W.ActiveDocument.Tables.Item(Table).Rows.Count;
icols:=W.ActiveDocument.Tables.Item(Table).Columns.Count;
StringGrid.RowCount:=irows;
StringGrid.ColCount:=icols;
for i:=1 to irows do
begin
for j:=1 to icols do
begin
GetWordTablesCellValue(Table,i,j,S);
StringGrid.Cells[j-1,i-1]:=S;
end;
end;
except
end;
end;
procedure GetStringGridInTable(StringGrid:TStringGrid;var Table:integer);
var
S:string;
icols,irows,iGridRows,jGridCols:integer;
begin
try
iCols:=StringGrid.ColCount;
iRows:=StringGrid.RowCount;
CreateTable(iRows,iCols,Table);
for iGridRows := 1 to iRows do
for jGridCols := 1 to iCols do
W.ActiveDocument.Tables.Item(Table).Cell(iGridRows, jGridCols).Range.Text:=
StringGrid.Cells[jGridCols - 1, iGridRows - 1];
W.ActiveDocument.Range.InsertAfter(' ');
Table:=W.ActiveDocument.Tables.Count;
W.ActiveDocument.Tables.Item(Table).AutoFitBehavior(wdAutoFitContent);
InsertParagraphAfterTable(Table);
except
end;
end;
procedure GetStringGridInTable2(StringGrid:TStringGrid;var Table:integer;ColArr:array of integer);
var
S:string;
icols,irows,iGridRows,jGridCols:integer;
begin
try
iCols:=Length(ColArr);
iRows:=StringGrid.RowCount;
CreateTable(iRows,iCols,Table);
for iGridRows := 1 to iRows do
for jGridCols := Low(ColArr) to High(ColArr) do
W.ActiveDocument.Tables.Item(Table).Cell(iGridRows, jGridCols+1).Range.Text:=
StringGrid.Cells[ColArr[jGridCols], iGridRows - 1];
W.ActiveDocument.Range.InsertAfter(' ');
Table:=W.ActiveDocument.Tables.Count;
W.ActiveDocument.Tables.Item(Table).AutoFitBehavior(wdAutoFitContent);
InsertParagraphAfterTable(Table);
except
end;
end;
procedure WordTableAddFromDBGrid(DBGrid: TDBGrid;CollSize:boolean;var Table:integer);
var i, j,Col,Row,ColWidth: Integer;
S:string;
begin
Col:=DBGrid.Columns.Count;
Row:=DBGrid.DataSource.DataSet.RecordCount+1;
//SetTextToDoc(DBGrid.Columns.Items[0].Title.Caption,true);
CreateTable(Row,Col,Table);
if CollSize then ColWidth:=DBGrid.Columns.Items[0].Width;
//W.Selection.Tables.Item(Table).Columns.Item(1).SetWidth(ColumnWidth:=ColWidth,RulerStyle:=wdAdjustNone);
For j:=0 To Col-1 Do
begin
S:=DBGrid.Columns.Items[j].Title.Caption;
SetWordTablesCellValue(Table,1,j+1,S);
if CollSize then ColWidth:=DBGrid.Columns.Items[j].Width;
//W.Selection.Tables.Item(Table).Columns.Item(j+1).
// SetWidth(ColumnWidth:=ColWidth,RulerStyle:=wdAdjustNone);
end;
DBGrid.DataSource.DataSet.First;
For i:=1 To Row-1 Do
begin
For j:=0 To Col-1 Do
SetWordTablesCellValue(Table,i+1,j+1,DBGrid.Columns.Items[j].Field.AsString);
DBGrid.DataSource.DataSet.Next;
end;
DBGrid.DataSource.DataSet.First;
W.ActiveDocument.Tables.Item(Table).AutoFitBehavior(wdAutoFitContent);
end;
Function SetSizeTable(Table:integer;RowsHeight, ColumnsWidth:real):boolean;
begin
SetSizeTable:=true;
try
W.ActiveDocument.Tables.Item(Table).Columns.Width:=ColumnsWidth;
W.ActiveDocument.Tables.Item(Table).Rows.Height:=RowsHeight;
except
SetSizeTable:=false;
end;
End;
Function GetSizeTable(Table:integer;var RowsHeight,ColumnsWidth:real):boolean;
begin
GetSizeTable:=true;
try
ColumnsWidth:=W.ActiveDocument.Tables.Item(Table).Columns.Width;
RowsHeight:=W.ActiveDocument.Tables.Item(Table).Rows.Height;
except
GetSizeTable:=false;
end;
End;
Function SetHeightRowTable(Table,Row:integer;RowHeight:real):boolean;
begin
SetHeightRowTable:=true;
try
W.ActiveDocument.Tables.Item(Table).Rows.item(Row).Height:=RowHeight;
except
SetHeightRowTable:=false;
end;
End;
Function GetHeightRowTable(Table,Row:integer;var RowHeight:real):boolean;
begin
GetHeightRowTable:=true;
try
RowHeight:=W.ActiveDocument.Tables.Item(Table).Rows.item(Row).Height;
except
GetHeightRowTable:=false;
end;
End;
Function SetWidthColumnTable(Table,Column:integer;ColumnWidth:real):boolean;
begin
SetWidthColumnTable:=true;
try
W.ActiveDocument.Tables.Item(Table).Columns.Item(Column).Width:=ColumnWidth;
except
SetWidthColumnTable:=false;
end;
End;
Function GetWidthColumnTable(Table,Column:integer;var ColumnWidth:real):boolean;
begin
GetWidthColumnTable:=true;
try
ColumnWidth:=W.ActiveDocument.Tables.Item(Table).Columns.Item(Column).Width;
except
GetWidthColumnTable:=false;
end;
End;
Function SetTextToTable(Table:integer;Row,Column:integer;text:string):boolean;
begin
SetTextToTable:=true;
try
W.ActiveDocument.Tables.Item(Table).Columns.Item(Column).Cells.Item(Row).Range.Text:=text;
except
SetTextToTable:=false;
end;
End;
Procedure GetTextFromTable(Table:integer;Row,Column:integer;var text:string);
begin
try
text:=W.ActiveDocument.Tables.Item(Table).Columns.Item(Column).Cells.Item(Row).Range.Text;
except
end;
End;
Function SetLineStyleBorderTable(Table:integer;Row,Column,wdBorderType,wdBorderStyle:wdUnits):boolean;
begin
SetLineStyleBorderTable:=true;
try
W.ActiveDocument.Tables.Item(Table).Columns.Item(Column).Cells.Item(Row).Borders.Item(wdBorderType).LineStyle:=wdBorderStyle;
except
SetLineStyleBorderTable:=false;
end;
End;
Function SetMergeCellsTable(Table:integer;Row1,Column1,Row2,Column2:integer):boolean;
var cel_:variant;
begin
SetMergeCellsTable:=true;
try
cel_:=W.ActiveDocument.Tables.Item(Table).Cell(Row2,Column2);
W.ActiveDocument.Tables.Item(Table).Cell(Row1,Column1).Merge(cel_);
except
SetMergeCellsTable:=false;
end;
End;
Function CopyHereRawFromTable(table,Row1,Row2:integer):boolean;
var
Here:integer;
begin
Here:=W.Selection.Start;
W.Selection.Start:=W.ActiveDocument.Tables.Item(Table).Rows.Item(Row1).Range.start;
W.Selection.End:=W.ActiveDocument.Tables.Item(Table).Rows.Item(Row2).Range.end;
W.Selection.Copy;
W.Selection.Start:=Here;
W.Selection.PasteAndFormat (0);
end;
procedure TableAutoFit(Table:integer);
begin
W.ActiveDocument.Tables.Item(Table).AutoFitBehavior(wdAutoFitContent);
end;
Procedure MakeNewLineInTable(Table,AfterRow,NewRowCount:integer);
begin
try
W.ActiveDocument.Tables.Item(Table).Rows.Item(AfterRow).Select;
W.Selection.InsertRowsBelow(NewRowCount);
except
end;
End;
Procedure DeleteRowInTable(Table,Row:integer);
begin
try
W.ActiveDocument.Tables.Item(Table).Rows.Item(Row).Select;
W.Selection.Rows.Delete;
except
end;
End;
procedure InsertPicture(FileName:string);
begin
W.Selection.InlineShapes.AddPicture(FileName);
W.ActiveDocument.Range.InsertParagraphAfter;
end;
end.
