给出一个Excel,如何读出Excel的数据(行,列数未知),要求一行一行的读,因为要对数据分析,并把读出所有数据到文本文件。
关键是如何读出Excel的数据。谢谢高手!
关键是如何读出Excel的数据。谢谢高手!
解决方案 »
- 谁能提供一些关于操作OutLook Expreee的资料
- delphi中有没有什么控件或者函数能够访问pci卡传输过来的数据信息?
- 在dbgrid中,网格带了下拉之后,总是要回两次车才能移到右边的一列,能不能一次即选定,同时又将光标右移一列呢?
- delphi创建dll的问题!急
- 哪儿有游戏的半成品,我想下载下来,学习学习,500
- 关于DATETIME类型的字段如何加加减得到新的时间??
- 高分求助,解决立即给分
- 在线等待:救我
- 急:(100分酬谢)如何写密码确认的代码(在线等候)
- 如何在DELPHI中使用UNICODE
- 欢迎大家加入软件技术QQ群:640705
- 请问Delphi如何向Oracle中插入日期格式的数据
然后
query1.first
while not query1.eof do
begin
处理
query1.next;
end;
MyExcel,MyWorkBook,MyWorkSheet: Variant;
MyExcel:= CreateOleObject('Excel.Application');
MyWorkBook:= MyExcel.WorkBooks.Add;
MyWorkSheet:= MyExcel.WorkSheets['Sheet'];
vValue:=VarToStr(ExlApp.ActiveSheet.Cells[Row,Col]);
procedure TForm1.Button3Click(Sender: TObject);
var
I,J : integer;
MyList: TStringList;
begin
try
MyList:=TStringList.Create;
MyList.Clear;
SourceConnection1.Connected:=false;
SourceConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Password="";'+
'Data Source='+Trim(Edit2.Text)+
';Mode=Read;Extended Properties=Excel 8.0;Persist Security Info=True';
try
SourceConnection1.Connected:=true;
SourceTable1.Active:=true;
except
application.MessageBox('连接失败!','提示',mb_ok+mb_iconinformation);
exit;
end;
MyList.Text:=SourceTable1.FieldList.Text;
SourceTable1.First;
StringGrid1.ColCount:=MyList.Count+1;
StringGrid1.RowCount:=SourceTable1.RecordCount+1;
For i:=0 to MyList.Count-1 do
StringGrid1.Cells[i+1,0]:=MyList[i];
i:=0;
while not SourceTable1.Eof do
begin
For J:=0 to MyList.Count-1 do
begin
if SourceTable1.FieldByName(MyList[J]).Value<>null then
begin
StringGrid1.Cells[j+1,i+1] :=
ShowSomeNotVisibleString(SourceTable1.FieldByName(MyList[J]).Value);
end else
end;
StringGrid1.Cells[0,i]:=inttostr(i);
inc(i);
SourceTable1.Next;
end;
finally
Freeandnil(MyList);
end;
end;
一个Excel相当如一个库,一个单元相当于一个表