이건 퀀텀그리드로 한 것입니다.
하이퍼 그리드를 쓴지가 오래되서 그냥 이거 올리니 참조하세요..
// 그리드 초기화
//=========================== TreeList Column Init ===========================//
procedure TForm_RS11040.Delete_dxTreeList( Temp_TreeList : TdxTreeList; Node : TdxTreeListNode; Base_Count : Byte );
var
i, j : Integer;
begin
Temp_TreeList.CloseEditor;
if Temp_TreeList.ColumnCount <> Base_Count then
begin
for i := 1 to Temp_TreeList.ColumnCount - Base_Count do
begin
Temp_TreeList.Columns[Base_Count].Destroy;
end;
end;
if Temp_TreeList.Count <> 0 then
begin
for i := 0 to Temp_TreeList.Count do
begin
Node := Temp_TreeList.TopNode;
if ( Node <> nil ) then Node.Destroy;
end;
end;
end;
// 칼럼 동적 생성
//====================== TreeList Dynamic Column Create ======================//
procedure TForm_RS11040.Create_dxTreeList( Temp_TreeList : TdxTreeList; Node : TdxTreeListNode; Band_Index, Base_Count : Byte;
var Temp_Array : TKeyArray );
var
iIndex : Byte;
dxTreeListCurrencyColumn : TdxTreeListCurrencyColumn;
sName : String;
begin
Temp_TreeList.CloseEditor;
//컬럼에 값 삽입
//========================== Dynamic Arrary Create ===========================//
function TForm_RS11040.Size_Count( Temp_dxMemData : TdxMemData; FieldName : String ) : TKeyArray;
var
i : Byte;
begin
SetLength( Result, Temp_dxMemData.RecordCount );
i := 0;
with Temp_dxMemData do
begin
First;
while Not EOF do
begin
Result[i] := Temp_dxMemData.FieldByName( FieldName ).Value;
Inc( i );
Next;
end;
end;
end;
// 엑셀에서 로드
procedure TForm_SC01230.SpeedButton_ExcelClick(Sender: TObject);
var
ExcelApp, ExcelSheet, ExcelFile : Variant;
iRow, iCol, iXLRows, iXLCols : Integer;
ExcelValue : Variant;
begin
SpeedButton_Save.Enabled := False;
prc_DisMsg( Panel_Msg, clBlack, 'Excel Data Loading...' ) ;
for iRow := 2 to iXLRows do
begin
Append;
for iCol := 1 to iXLCols do
begin
dxMemData_Main.Fields[iCol].AsString := EXcelSheet.Cells[iRow, iCol];
ProgressBar1.Position := ProgressBar1.Position + 1;
end;
end;
end;
하이퍼 그리드를 쓴지가 오래되서 그냥 이거 올리니 참조하세요..
// 그리드 초기화
//=========================== TreeList Column Init ===========================//
procedure TForm_RS11040.Delete_dxTreeList( Temp_TreeList : TdxTreeList; Node : TdxTreeListNode; Base_Count : Byte );
var
i, j : Integer;
begin
Temp_TreeList.CloseEditor;
if Temp_TreeList.ColumnCount <> Base_Count then
begin
for i := 1 to Temp_TreeList.ColumnCount - Base_Count do
begin
Temp_TreeList.Columns[Base_Count].Destroy;
end;
end;
if Temp_TreeList.Count <> 0 then
begin
for i := 0 to Temp_TreeList.Count do
begin
Node := Temp_TreeList.TopNode;
if ( Node <> nil ) then Node.Destroy;
end;
end;
end;
// 칼럼 동적 생성
//====================== TreeList Dynamic Column Create ======================//
procedure TForm_RS11040.Create_dxTreeList( Temp_TreeList : TdxTreeList; Node : TdxTreeListNode; Band_Index, Base_Count : Byte;
var Temp_Array : TKeyArray );
var
iIndex : Byte;
dxTreeListCurrencyColumn : TdxTreeListCurrencyColumn;
sName : String;
begin
Temp_TreeList.CloseEditor;
sName := '_SIZE';
for iIndex := Low( Temp_Array ) to High( Temp_Array ) do
begin
dxTreeListCurrencyColumn := TdxTreeListCurrencyColumn.Create( Temp_TreeList );
dxTreeListCurrencyColumn.Name := Temp_TreeList.Name + sName + IntToStr(iIndex);
dxTreeListCurrencyColumn.TreeList := Temp_TreeList;
dxTreeListCurrencyColumn.BandIndex := Band_Index;
dxTreeListCurrencyColumn.HeaderAlignMent := taCenter;
dxTreeListCurrencyColumn.ReadOnly := False;
dxTreeListCurrencyColumn.Alignment := taRightJustify;
dxTreeListCurrencyColumn.RowIndex := 0;
dxTreeListCurrencyColumn.Index := Temp_TreeList.ColumnCount;
dxTreeListCurrencyColumn.HeaderMaxLineCount := 1;
dxTreeListCurrencyColumn.DisableEditor := True;
dxTreeListCurrencyColumn.DisplayFormat := '#,##0';
dxTreeListCurrencyColumn.Caption := Temp_Array[iIndex];
dxTreeListCurrencyColumn.Width := 60;
end;
end;
//컬럼에 값 삽입
//========================== Dynamic Arrary Create ===========================//
function TForm_RS11040.Size_Count( Temp_dxMemData : TdxMemData; FieldName : String ) : TKeyArray;
var
i : Byte;
begin
SetLength( Result, Temp_dxMemData.RecordCount );
i := 0;
with Temp_dxMemData do
begin
First;
while Not EOF do
begin
Result[i] := Temp_dxMemData.FieldByName( FieldName ).Value;
Inc( i );
Next;
end;
end;
end;
// 엑셀에서 로드
procedure TForm_SC01230.SpeedButton_ExcelClick(Sender: TObject);
var
ExcelApp, ExcelSheet, ExcelFile : Variant;
iRow, iCol, iXLRows, iXLCols : Integer;
ExcelValue : Variant;
begin
SpeedButton_Save.Enabled := False;
prc_DisMsg( Panel_Msg, clBlack, 'Excel Data Loading...' ) ;
try
ExcelApp := CreateOLEObject( 'Excel.Application' );
except
MessageDlg( 'Excel 이 설치되지 않았습니다!', mtInformation, [mbOk], 0 );
Exit;
end;
try
ExcelApp.Visible := False;
ExcelApp.DisplayAlerts := False;
OpenDialog1.InitialDir := ExtractFilePath( Application.ExeName );
if OpenDialog1.Execute then
begin
ExcelFile := ExcelApp.WorkBooks.Open( OpenDialog1.FileName );
ExcelFile := ExcelApp.WorkBooks.Item[1];
ExcelSheet := ExcelFile.Worksheets.Item[1];
iXLCols := ExcelSheet.UsedRange.Columns.Count;
iXLRows := ExcelSheet.UsedRange.Rows.Count;
ProgressBar1.Max := iXLCols * iXLRows ;
ProgressBar1.Position := 0 ;
with dxMemData_Main do
begin
Close;
Open;
for iRow := 2 to iXLRows do
begin
Append;
for iCol := 1 to iXLCols do
begin
dxMemData_Main.Fields[iCol].AsString := EXcelSheet.Cells[iRow, iCol];
ProgressBar1.Position := ProgressBar1.Position + 1;
end;
end;
end;
ProgressBar1.Position := 0 ;
ExcelApp.WorkBooks.Close;
ExcelApp.Quit;
Unassigned;
end;
prc_DisMsg( Panel_Msg, clBlack, 'Excel Loading Complete!' ) ;
SpeedButton_Save.Enabled := True;
except
on err:exception do
begin
ProgressBar1.Position := 0 ;
ExcelApp.WorkBooks.Close;
ExcelApp.Quit;
ExcelApp := Unassigned;
MessageDlg( '작업이 취소되었습니다. Data확인요망-'+err.message, mtInformation, [mbOk], 0 );
end;
end;
end;