主题:delphi读取excel表内容问题请教??
在delphi中通过server的Excel组件来读取Excel表中的内容,
代码:
ExcelApplication1.Connect;
ExcelApplication1.Visible[0]:=false;
try
ExcelApplication1.Workbooks.Open(ExtractFilePath(paramstr(0))+'import.xls',null,null,null,null,null,null,null,null,null,null,null,null,0);
except
ExcelApplication1.Disconnect
end;
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]); ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _Worksheet);
//ExcelWorksheet1.UsedRange.Rows.Count;想取行数,出错
遇到一些问题:
1、如果我想自己选择Excel文件打开,而不是当前目录下的指定文件;
2、用ExcelWorksheet1.UsedRange.Rows.Count;想取行数,但出错
请仁兄赐教!!!
代码:
ExcelApplication1.Connect;
ExcelApplication1.Visible[0]:=false;
try
ExcelApplication1.Workbooks.Open(ExtractFilePath(paramstr(0))+'import.xls',null,null,null,null,null,null,null,null,null,null,null,null,0);
except
ExcelApplication1.Disconnect
end;
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]); ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _Worksheet);
//ExcelWorksheet1.UsedRange.Rows.Count;想取行数,出错
遇到一些问题:
1、如果我想自己选择Excel文件打开,而不是当前目录下的指定文件;
2、用ExcelWorksheet1.UsedRange.Rows.Count;想取行数,但出错
请仁兄赐教!!!