08-10-2023, 09:31 PM
السلام عليكم
هل هذا الخطأ من عدم غلق الأكسيل أو ماذا؟
رسالة الخطأ
OLE error 800Ao033EC
الكود
هل هذا الخطأ من عدم غلق الأكسيل أو ماذا؟
رسالة الخطأ
OLE error 800Ao033EC
الكود
كود :
uses
comobj
private
{ Private declarations }
ExcelFile,sheet : Variant;
procedure TForm2.Button1Click(Sender: TObject);
Var
MaxRow, MaxCol,i,j:Integer;
begin
if OpenDialog1.Execute then
ExcelFile := CreateOleObject('Excel.Application');
ExcelFile.visible:=0;
ExcelFile.DisplayAlerts := False;
ExcelFile.Workbooks.Open(OpenDialog1.FileName);
sheet := ExcelFile.WorkSheets[1];
MaxRow := Sheet.Usedrange.Rows.count ;
MaxCol := sheet.Usedrange.Columns.count;
stringgrid1.RowCount:=maxRow+1;
StringGrid1.ColCount:=maxCol+1;
stringgrid1.Cells[1,i]:=excelfile.cells[i,1].value;;
stringgrid1.Cells[2,i]:=excelfile.cells[i,2].value;
stringgrid1.Cells[3,i]:=excelfile.cells[i,3].value;
ExcelFile.workbooks.close;
ExcelFile.quit;
ExcelFile:=Unassigned;
end;