//读excel
function TForm1.readExcel(fileName :WideString):TStringList;
var
I, J ,len,ret: Integer;
MaxRow, MaxCol: Integer;
List, Strs: TStringList;
ExcelApp, Sheet: Variant;
OldTime: TDateTime;
strChar:WideChar;
str:WideString;
begin
ListINFO := TStringList.Create;
Strs := TStringList.Create;
// 创建一个excel的ole对象
ExcelApp := CreateOleObject('Excel.Application');
try
// 打开一个excel文件
ExcelApp.WorkBooks.Open(fileName);
ListINFO.BeginUpdate;
try
// 设置工作区
ExcelApp.WorkSheets[1].Activate;
Sheet := ExcelApp.WorkSheets[1];
// 有数据的区域的行数和列数
MaxRow := Sheet.UsedRange.Rows.count;
MaxCol := Sheet.UsedRange.Columns.count;
for I := 2 to MaxRow do
begin
Strs.Clear;
for J := 1 to MaxCol do
begin
// 获得excel的数据第i行,第j列单元格
function TForm1.readExcel(fileName :WideString):TStringList;
var
I, J ,len,ret: Integer;
MaxRow, MaxCol: Integer;
List, Strs: TStringList;
ExcelApp, Sheet: Variant;
OldTime: TDateTime;
strChar:WideChar;
str:WideString;
begin
ListINFO := TStringList.Create;
Strs := TStringList.Create;
// 创建一个excel的ole对象
ExcelApp := CreateOleObject('Excel.Application');
try
// 打开一个excel文件
ExcelApp.WorkBooks.Open(fileName);
ListINFO.BeginUpdate;
try
// 设置工作区
ExcelApp.WorkSheets[1].Activate;
Sheet := ExcelApp.WorkSheets[1];
// 有数据的区域的行数和列数
MaxRow := Sheet.UsedRange.Rows.count;
MaxCol := Sheet.UsedRange.Columns.count;
for I := 2 to MaxRow do
begin
Strs.Clear;
for J := 1 to MaxCol do
begin
// 获得excel的数据第i行,第j列单元格