안녕하세요
수고 많습니다..
자료를 다운을 받아서 작업을 하고 있습니다.
그런데 error가 발생하여 질문을 합니다.
uses
ComObj;
ExcelApp.WorkBooks.Close;
ExcelApp.quit;
ExcelApp := UnAssigned;/// 이부분에서 undeclared identifier. 'Unassigned'
errorr 가 발생합니다.
분명한것은 해제를 시키 주어야하는데...
무엇때문에 그런지 이유를 모르겠습니다.
많은 답변을 부탁 드립니다.
그럼 수고 하세요
procedure TDemo.SpeedButton2Click(Sender: TObject);
var
ExcelApp, ExcelBook, ExcelSheet, Sheets: Variant;
I, J, s : Integer; // 순환변수
begin
try //엑셀이 설치되었있을 경우만 가능
ExcelApp := CreateOLEObject('Excel.Application'); //엑셀을 실행
except
ShowMessage('Excel이 설치되어 있지 않습니다!!!');
Exit;
end;
try
ExcelApp.Visible := False;
ExcelApp.DisplayAlerts := False;
if OpenDialog1.Execute then
begin //엑셀 통합문서 열기
ExcelBook := ExcelApp.WorkBooks.Open(OpenDialog1.FileName);
ExcelBook := ExcelApp.WorkBooks.item[1]; //워크 쉬트 설정
ExcelSheet := ExcelBook.Worksheets.Item[1]; //일단 개별문서는 sheet1으로 고정
advStringGrid1.RowCount := ExcelSheet.UsedRange.Rows.Count + 1; //StringGrid 초기화 (Title은 고려하지 않았습니다.)
advStringGrid1.ColCount := ExcelSheet.UsedRange.Columns.Count + 1;
S := 0;
for I := 0 to EXCELSheet.UsedRange.Rows.count do
begin
S := I - 1;
for J := 0 to ExcelSheet.UsedRange.Columns.count do
begin
if j = 0 then
begin
if s > 0 then
//advStringGrid1.Cells[J,I] := intTostr(I); //스트링그리드에 뿌리기
end
else
advStringGrid1.Cells[J,I] := (ExcelSheet.Cells[J,i]); //스트링그리드에 뿌리기
end;
end;
ExcelApp.WorkBooks.Close;
ExcelApp.quit;
ExcelApp := UnAssigned;// 이부분에서 undeclared identifier. 'Unassigned'
end;
except
on err : exception do
begin
ExcelApp.WorkBooks.Close;
ExcelApp.quit;
ExcelApp := unassigned;
ShowMessage('작업이 취소되었습니다. Data확인요망-'+err.message);
end;
end;
ShowMessage(IntToStr(ExcelSheet.UsedRange.Rows.Count) + '건의 자료를 변환하였습니다');
end;