제가 아래와 같이 테스트 해봤습니다.
참조 하세요.
Row, Col 수량을 4000씩 잡았습니다.
하기와 같이 하면 약 6~7초 정도 걸렸습니다.
int row = StringGrid1->RowCount - 1;
int col = StringGrid1->ColCount - 1;
unsigned long tt = GetTickCount();
for(int j = 1; j < row + 1; j++) StringGrid1->Rows[j]->BeginUpdate();
for(int i = 1; i < col + 1; i++) StringGrid1->Cols[i]->BeginUpdate();
for(int j = 1; j < row + 1; j++)
{
for(int i = 1; i < col + 1; i++)
{
StringGrid1->Cells[i][j] = IntToStr(i);
}
}
for(int j = 1; j < row + 1; j++) StringGrid1->Rows[j]->EndUpdate();
for(int i = 1; i < col + 1; i++) StringGrid1->Cols[i]->EndUpdate();
Caption = GetTickCount() - tt;
하기와 같이 하면 약17초 정도 걸리거더군요.
int row = StringGrid1->RowCount - 1;
int col = StringGrid1->ColCount - 1;
unsigned long tt = GetTickCount();
for(int j = 1; j < row + 1; j++)
{
for(int i = 1; i < col + 1; i++)
{
StringGrid1->Cells[i][j] = IntToStr(i);
}
}
Caption = GetTickCount() - tt;
이것도 느리면 타이머를 사용해서 조금씩 변경하는 방법이 있습니다.
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
/*
외부에서 FRowIndex를 0으로 하면 다시 갱신하는 구조입니다. ^^;;
전체를 다 갱신하면 FRowIndex가 RowCount보다 많기 때문에 갱신작업을 하지 않을껍니다.
*/
if(FRowIndex > StringGrid1->RowCount)
{
Caption = "갱신 완료!";
return;
}
int r;
for(r = 0; r < 100; r++)
{
for(int c = 0; c < StringGrid1->ColCount; c++)
{
StringGrid1->Cells[c][FRowIndex + r] = IntToStr(c);
}
}
Caption = "갱신 중!";
FRowIndex += r;
}
//---------------------------------------------------------------------------
Ps. 1번과 3번을 섞으면 좀더 빠르겠죠? ^^;
답변이 되실련지 모르겠네요.
그럼 즐프하세요~ ^^//
김태우 님이 쓰신 글 :
: for(int j = 1; j < row+1; j++)
: {
:
: for(int i = 1; i < col+1; i++)
: {
:
: StringGrid1->Cells[i][j] = XLSheet.OlePropertyGet("Cells", j , i).OlePropertyGet("Value");
: StringGrid1->Cells[0][j] = IntToStr(j);
: StringGrid1->Cells[i][0] = IntToStr(i);
: }
: }
:
: StringGrid1->Rows[0]->BeginUpdate();
: 이렇게 밖에 사용을 못하나요??
:
: 그러면 이렇게 엑셀에서 읽어온값을 그리드에 넣어줄때..
: 어떻게 사용해야되는건지...
: 초보입니다.. 부탁드리겠습니다.
: 검색을 해봐도.. 제가 적용하면 마찬가지로 프로그램이 용량이큰엑셀은 30초 정도는 멈춰 있네요..