求大神给我注释一下
var
Excel: OleVariant;
iRow,iCol : integer;
xlsFilename: string;
begin
OpenDialog1.Title := '请选择正确的excel文件';
OpenDialog1.Filter := 'Excel(*.xls)|*.xls';
if OpenDialog1.Execute then
begin
xlsFilename := OpenDialog1.FileName;
try
Excel := CreateOLEObject('Excel.Application');
except
Application.MessageBox('excel没有安装', '提示信息', MB_OK+MB_ICONASTERISK+MB_DEFBUTTON1+MB_APPLMODAL);
Exit;
end;
ADOQ1.Close;
ADOQ1.Open;
ADOQ1.Filtered := false;
Excel.Visible := false;
Excel.WorkBooks.Open(xlsFilename);
try
iRow := 2;
iCol := 1;
while trim(Excel.WorkSheets[1].Cells[iRow,iCol].value) <> '' do
begin
if ADOQ1.Locate('years',trim(Excel.WorkSheets[1].Cells[iRow,iCol].value),[loCaseInsensitive]) then
begin
if not ADOQ1.FieldByName('audit').AsBoolean then
begin
ADOQ1.Edit;
ADOQ1.FieldByName('quantity').Value := StrToFloat(trim(Excel.WorkSheets[1].Cells[iRow,iCol+6].value));
ADOQ1.Post;
end
else
begin
ADOQ1.Insert;
ADOQ1.FieldByName('years').Value := trim(Excel.WorkSheets[1].Cells[iRow,iCol].value);
ADOQ1.FieldByName('quantity').Value := StrToFloat(trim(Excel.WorkSheets[1].Cells[iRow,iCol+6].value));
ADOQ1.Post;
end;
end
else
begin
ADOQ1.Insert;;
ADOQ1.FieldByName('years').Value := trim(Excel.WorkSheets[1].Cells[iRow,iCol].value);
ADOQ1.FieldByName('quantity').Value := StrToFloat(trim(Excel.WorkSheets[1].Cells[iRow,iCol+6].value));
ADOQ1.Post;
end;
iRow := iRow + 1;
end;
Excel.Quit;
MessageDlg('数据导入完成!',mtInformation,[mbOk],0);
except
Excel.Quit;
raise;
end;
ADOQ1.Close;
ADOQ1.Open;
end;
end;
Excel: OleVariant;
iRow,iCol : integer;
xlsFilename: string;
begin
OpenDialog1.Title := '请选择正确的excel文件';
OpenDialog1.Filter := 'Excel(*.xls)|*.xls';
if OpenDialog1.Execute then
begin
xlsFilename := OpenDialog1.FileName;
try
Excel := CreateOLEObject('Excel.Application');
except
Application.MessageBox('excel没有安装', '提示信息', MB_OK+MB_ICONASTERISK+MB_DEFBUTTON1+MB_APPLMODAL);
Exit;
end;
ADOQ1.Close;
ADOQ1.Open;
ADOQ1.Filtered := false;
Excel.Visible := false;
Excel.WorkBooks.Open(xlsFilename);
try
iRow := 2;
iCol := 1;
while trim(Excel.WorkSheets[1].Cells[iRow,iCol].value) <> '' do
begin
if ADOQ1.Locate('years',trim(Excel.WorkSheets[1].Cells[iRow,iCol].value),[loCaseInsensitive]) then
begin
if not ADOQ1.FieldByName('audit').AsBoolean then
begin
ADOQ1.Edit;
ADOQ1.FieldByName('quantity').Value := StrToFloat(trim(Excel.WorkSheets[1].Cells[iRow,iCol+6].value));
ADOQ1.Post;
end
else
begin
ADOQ1.Insert;
ADOQ1.FieldByName('years').Value := trim(Excel.WorkSheets[1].Cells[iRow,iCol].value);
ADOQ1.FieldByName('quantity').Value := StrToFloat(trim(Excel.WorkSheets[1].Cells[iRow,iCol+6].value));
ADOQ1.Post;
end;
end
else
begin
ADOQ1.Insert;;
ADOQ1.FieldByName('years').Value := trim(Excel.WorkSheets[1].Cells[iRow,iCol].value);
ADOQ1.FieldByName('quantity').Value := StrToFloat(trim(Excel.WorkSheets[1].Cells[iRow,iCol+6].value));
ADOQ1.Post;
end;
iRow := iRow + 1;
end;
Excel.Quit;
MessageDlg('数据导入完成!',mtInformation,[mbOk],0);
except
Excel.Quit;
raise;
end;
ADOQ1.Close;
ADOQ1.Open;
end;
end;
...全文
相关推荐
二分法求方程的根(详细注释)
matlab求方程的根,注释很详细,同时利用了递归的思想,对于理解二分法原理非常有用。
拓扑排序 拓扑排序 有注释 邻接表形式的 求入度的
拓扑排序 有注释 邻接表形式的 求入度的
MATLAB差分进化算法求目标函数极值(含代码、注释)(实例3)
MATLAB差分进化算法求目标函数极值(含代码、注释)(实例3)离散差分算法求目标函数极值
MATLAB差分进化算法求目标函数极值(含代码、注释)(实例2)
MATLAB差分进化算法求目标函数极值(含代码、注释)(实例2)离散差分算法求目标函数极值
MATLAB差分进化算法求目标函数极值(含代码、注释)(实例1)
MATLAB差分进化算法求目标函数极值(含代码、注释)(实例1)离散差分算法求目标函数极值


语言基础/算法/系统设计
