level 8
ooooh_up
楼主

word中有表格如上,根本不能转换成txt、excel等格式,什么粘贴复制都不成,procedure TForm2.SpeedButton1Click(Sender: TObject);
var
i,c:integer;
myTable: Table;
s:string;
begin
wordApp := TWordApplication.Create(nil);
WordApp.Connect;
WordApp.Visible := true;
wordDoc.ConnectTo(wordApp.Documents.Open('D:\小学语文练习题.doc',EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam));
WordDoc.Activate;
If wordDoc.Tables.Count > 0 Then begin
mytable:=wordDoc.Tables.Item(1);
c:=wordDoc.Tables.Item(1).rows.Count;
end
Else begin
showmessage('无表格');
exit;
end;
//从这儿开始就不大会了,刚接触数据库,对命令不是太懂,values中的值能否直接取mytable的数据?应该怎么写?
with ADOQuery1 do
begin
close;
SQL.clear;
SQL.Add('insert into 一年级 (题目文本) values(a)');
parameters.ParamByName('a').Value:=s;
ExecSQL;
//这个运行时提示找不到'题目文本'。
for I := 1 to c do begin
s:= mytable.Cell(i,1).range.text;
fieldByName('题目文本').asString:=s;
next;
end;
end;
end;
