Скачиваний:
0
Добавлен:
07.03.2018
Размер:
2.87 Кб
Скачать
unit Unit2;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, Vcl.StdCtrls, Vcl.Grids,
Vcl.DBGrids, Data.Win.ADODB, vcl.oleauto;

type
TForm2 = class(TForm)
ADOQProba: TADOQuery;
DSProba: TDataSource;
DBGProba: TDBGrid;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
OD: TOpenDialog;
procedure FormActivate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
var
f : TextFile ;
s : String ;
s1,s2 : String;
I : Integer ;
begin
od.filter:='текстовые файлы|*.txt|все файлы|*.*';
if od.execute then
begin
assignfile(f,od.FileName);
{$I-}
reset(f);
{$I+}
if ioresult=0 then
begin
while not eof(f) do
begin
readln(f,s);
for i := 1 to length(s) do
begin
if s[i] = '=' then
break;
end;
s1:=copy(s,1,I,-1);
s2:=copy(s,I+1,length(s)-I);
with adoqproba do
begin
with sql do
begin
clear;
add('INSERT INTO Data(poletext,poleint)VALUES('+ quotedstr(s1), + ','+ s2 + ')');
end;
execsql;
with sql do
begin
clear;
add('SELECT * FROM Data');
end;
active:= true;
end;
end;
end;
end;
end;

procedure TForm2.Button2Click(Sender: TObject);
var
excel : variant;
worksheet : olevariant;
s1,s2 : string;
J,D : integer;
row,col : integer;
range : variant;
begin
od.Filter:= 'документ Exel|*.xls;*.xlsx| все файлы';
if od.Execute then
begin
excel:= createoleobject('excel.application');
excel.workbooks.open(od.FileName);
for j := 1 to excel.activeworkbook.sheet.count do
begin
excel.activeworkbook.sheets.item[j].activate;
worksheet:=excel.activateworkbook.activesheet;
row := worksheet.usedrange.rows.count;
col := worksheet.usedrange.columns.count;
range:=worksheet.usedrange.value;
end;
end;
end;

procedure TForm2.FormActivate(Sender: TObject);
var
s,sdb : string;
begin
s:=extractfilepath(application.ExeName);
sdb := 'provider=microsoft.jet.4.0;datasource='+s+'database.mdb;persist info=false';
with adoqproba do
begin
active:=false;
connectionstring:=sdb;
active:=true;
with sql do
begin
with sql do
begin
clear;
add('SELECT * FROM Data');
end;
active:= True;
end;
end;
end;

end.
Соседние файлы в папке лаба 4 ( не до конца )
  • #
    07.03.201829.81 Кб0Project1.dproj
  • #
    07.03.2018730 б0Project1.dproj.local
  • #
    07.03.2018153 б0Project1.identcache
  • #
    07.03.2018158 б0Project1.stat
  • #
    07.03.20183.03 Кб0Unit2.dfm
  • #
    07.03.20182.87 Кб0Unit2.pas
  • #
    07.03.201811.89 Кб1Документ.docx
  • #
    07.03.20188.29 Кб1Книга.xlsx
  • #
    07.03.201878 б0Текст.txt