1. 随机取数就用
Randomize;
Row := Random(200); //0 -- 200之间的随机数
Col := Random(100); //0 -- 100 之间的随机数
然后
ExcelWorkSheet1.Cells.Item[Row,Col]取得单元格的数值
2. 指定sheet如下:
xlApp.Connect;
xlBook.ConnectTo(xlApp.Workbooks.Open('E:/book1.xls',NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0));
xlSheet.ConnectTo(xlBook.Sheets[1] as _WorkSheet);
其中xlSheet就指向了sheet1了; xlApp : TExcelApplication;
xlBook : TExcelWorkBook, xlSheet : TExcelWorkSheet.