무슨 에러인지 도무지 모르겠어여! 어젠 밤을 꼬박새웠답니다! 아침까정........쭉~~ㅜㅜ
나름데로 이렇게저렇게 해봤는데도! 도무지 해결이 안됩니다.
참고로 아래 소스는 폼이 없는 unit입니다. 그리고 다른 폼에서 메소드를 사용합니다.
TObjectList라는것이 있다고해서 바꿔보려했는데 첨쓰는거라서 그런지 아래와 같은 기능을
하도록 구현을 못하겠더라구여! ㅜㅜ; 소스 함 봐주세요!
즐건 하루 보내시구여! 참고로 for문 돌리는 값에 문제가 있는거 같은데...
프로시저 - InterfaceEngin중에서 for f1 := 2 to ShtCnt do begin이 있는데 부분에서여...
for문이 f1과 ChtCnt값에 만족해서 for문을 탈출하려할때 오류가 발생합니다.
탈출당시의 값을 hint로 보자면 f1 = 6 ChtCnt = 5값에서 for벗어나려고할때...
-------------------------------------------------------------------------------------------------
type
TAryTabSheet = Array of TTabSheet;
TSheetScrol = Array of TScrollBox;
TStrGrid = Array of TStringGrid;
var //전력변수 선언
XL, WorkBK, Worksheet: Variant;
FilePath: String;
FileCnt, ShtCnt: Integer;
FileName: Array of String;
-------------------------------------------------------------------------------------------------
procedure ExcelLoading;
begin
try
XL := CreateOLEObject('Excel.Application'); //uses 'ComObj' 사용.
XL.WorkBooks.Open(ExtractFilePath(Application.ExeName)+'Infomation.xls');
WorkBK := XL.WorkBooks.item[1];
XL.visible := FALSE;
ShtCnt := WorkBK.WorkSheets.count;
WorkSheet := WorkBK.WorkSheets.Item[1];
except
ShowMessage('Excel이 설치되어 있지 않습니다!');
end;
end;
----------------------------------------------------------------------------------------------------
procedure ConfigSetting(frmName: TForm; ValueList: TValueListEditor; var FileList: TFileListBox);
var
i, x: smallInt;
begin
for x := 1 to WorkSheet.Cells.CurrentRegion.Rows.Count do begin
ValueList.InsertRow(WorkSheet.Cells[x, 1], WorkSheet.Cells[x, 2], true);
end;
if ValueList.Values['ConnectMode'] = 'Local' then FilePath := ValueList.Values['Local']
else FilePath := ValueList.Values['ftpPath'];
FileList.Directory := FilePath+'\';
FileList.Mask := '*.itf';
FileCnt := FileList.Count;
SetLength(FileName, FileList.Count);
for i := 0 to FileCnt-1 do begin
FileName[i] := FileList.Items[i];
end;
end;
-----------------------------------------------------------------------------------------------------
procedure InterfaceEngin(frmName: TForm; PageName: TPageControl);
var
tmpBuff: String;
f1, f2, f3, f4, ACnt, OneCnt, vCol, vRow: Integer;
AryTabSheet : TAryTabSheet;
SheetScrol : TSheetScrol;
StrGrid : TStrGrid;
AllData, OneData : TStringList;
begin
SetLength(AryTabSheet, ShtCnt);
SetLength(SheetScrol, ShtCnt);
for f1 := 2 to ShtCnt do begin
for f2 := 0 to FileCnt-1 do begin
AllData := TStringList.Create;
if (Copy(FileName[f2], 1, 6) = WorkBK.WorkSheets.item[f1].Name) then begin
WorkSheet := WorkBK.WorkSheets.Item[f1];
AryTabSheet[f1] := TTabSheet.Create(nil);
AryTabSheet[f1].PageControl := PageName;
AryTabSheet[f1].Parent := PageName;
AryTabSheet[f1].Caption := WorkBK.WorkSheets.item[f1].Name;
SheetScrol[f1] := TScrollBox.Create(nil);
SheetScrol[f1].Align := alClient;
SheetScrol[f1].Parent := AryTabSheet[f1];
SheetScrol[f1].Ctl3D := FALSE;
vCol := WorkSheet.Cells.CurrentRegion.Columns.Count;
vRow := WorkSheet.Cells.CurrentRegion.Rows.Count;
AllData.LoadFromFile(FilePath+'\'+FileName[f2]);
SetLength(StrGrid, AllData.Count);//+1
for ACnt := AllData.Count-1 downto 0 do begin
OneData := TStringList.Create;
tmpBuff := StringReplace(AllData[ACnt], '"', '"', [rfReplaceAll]);
OneData.Clear;
OneDataAsSplit(PChar(tmpBuff), '|', '~', OneData);
if OneData.Count > 3 then begin//LOAD된 데이타가 필드와 맞지 않을경우 다음으로 넘긴다.
StrGrid[ACnt+1] := TStringGrid.Create(SheetScrol[f1]);
StrGrid[ACnt+1].Parent := SheetScrol[f1];
StrGrid[ACnt+1].Align := alLeft;
StrGrid[ACnt+1].Ctl3D := FALSE;
StrGrid[ACnt+1].FixedCols := 0;
StrGrid[ACnt+1].FixedRows := 0;
StrGrid[ACnt+1].Font.Name := '굴림체';
StrGrid[ACnt+1].Font.Size := 9;
StrGrid[ACnt+1].ColCount := vCol+1;
StrGrid[ACnt+1].RowCount := vRow;
StrGrid[ACnt+1].Options := [goVertLine,goHorzLine,goRowSelect];
for f3 := 0 to vCol-1 do begin
for f4 := 0 to vRow do begin
StrGrid[ACnt+1].Cells[f3, f4] := WorkSheet.Cells[f4+1, f3+1];
end;
end;
for OneCnt := 0 to OneData.Count-1 do begin
StrGrid[ACnt+1].Cells[StrGrid[ACnt+1].ColCount, OneCnt] := Trim(OneData[OneCnt]);
end;
OneData.Free;
end;
end;
AllData.Free;
end;
end;
end;
end;
SetLength(AryTabSheet, ShtCnt); <= 이렇게 정의 되어 있으니..