如何判断Excel表格有多少条记录?谢谢! 如何判断Excel表格有多少条记录?谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用语句 ExcelApp.WorkSheets[1].UsedRange.Rows.Count; 可以取到表的最大行数 使用ADO读取,然后对得到的数据机进行操作 下面的代码可以解决你的问题: ExcelApp.ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell,EmptyParam).Activate; lastRow := ExcelApp.ActiveCell.Row; lastCol := ExcelApp.ActiveCell.Column; 先用ADO连接,然后象普通的表一样操作,记录条数就是recordcount http://www.kaer.cn/default.aspx有ADO连EXCEL的例子, procedure TfrmSG.Button1Click(Sender: TObject); //uses Excel2000, ComObjvar pc_i:integer; xlapp,sheet: variant; WBK: OleVariant;begin xlapp := createoleobject('excel.application'); if Trim(Edit1.Text)='' then begin Application.MessageBox('文件名不能为空','警告',MB_OK); Exit; end; WBK := xlapp.workbooks.Open(Edit1.Text); sheet := xlapp.workbooks[1].worksheets['sheet1']; sheet.Cells.SpecialCells(XlCellTypeLastCell,EmptyParam).Activate; showmessage(IntToStr(xlapp.ActiveCell.Row)); //行 showmessage(IntToStr(xlapp.ActiveCell.Column)); //列 pc_i:=1; Edit2.Text := sheet.cells[pc_i,1]; //写入的话用 sheet.cells[pc_i,1] := Edit2.Tex; WBK.Close(SaveChanges := True); xlapp.Quit;end; b_filedCount :=eclApp.ActiveSheet.UsedRange.columns.Count;//返回excel 表中的列数b_row :=eclApp.activesheet.UsedRange.rows.count; //返回excel 表中的行数 image 字段 判断 pchar与string如何转换? 新年新气象,祝各位在新的一年里,分多多,RMB多多! 用delphi如何作activex dll???? 请问如何获得当前cpu温度和使用率? 在线等待帮助! 新手,一个简单的录入问题。 我试过了,但不能永久的使用,在别的程序调用同一数据库的时候,还要重新设定,有别的高招吗? 100分求SQL中的一些小问题---很容易就得到了--进来看看 哪里有VisiBroker下载? delphi 访问远程 accesss 为什么会有too many actual parameters的错误信息?
ExcelApp.ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell,EmptyParam).Activate;
lastRow := ExcelApp.ActiveCell.Row;
lastCol := ExcelApp.ActiveCell.Column;
var
pc_i:integer;
xlapp,sheet: variant;
WBK: OleVariant;
begin
xlapp := createoleobject('excel.application');
if Trim(Edit1.Text)='' then
begin
Application.MessageBox('文件名不能为空','警告',MB_OK);
Exit;
end;
WBK := xlapp.workbooks.Open(Edit1.Text);
sheet := xlapp.workbooks[1].worksheets['sheet1'];
sheet.Cells.SpecialCells(XlCellTypeLastCell,EmptyParam).Activate; showmessage(IntToStr(xlapp.ActiveCell.Row)); //行
showmessage(IntToStr(xlapp.ActiveCell.Column)); //列
pc_i:=1;
Edit2.Text := sheet.cells[pc_i,1]; //写入的话用 sheet.cells[pc_i,1] := Edit2.Tex;
WBK.Close(SaveChanges := True);
xlapp.Quit;
end;