지금제가 쓰고 있는 것은 셀 단위로 excel에 넘기는데 자료건수가 많으면 excel이 죽어버리네요.
batchmove를 쓰면된다고 하는데 자세한 방법좀 가르쳐주세요. 예제가 있으면 더욱좋고요.부탁할께요. 아래는 제가쓰는 방법입니다.
var
XL, XLBook: Variant;
i, j, k: longint;
sj,si, T: integer;
title : string;
CH,CHA,ACH : STRING;
p : REAL ;
begin
title := '제품출고 현황' ;
CreateOLEObject('Excel.Application');
with stringgrid1 do
begin
try
XL := GetActiveOLEObject('Excel.Application');
except
on E: EOleSysError do
begin
try
XL := CreateOLEObject('Excel.Application'); //엑셀을 실행
except
MessageDlg('Excel이 설치되어 있지 않습니다.', MtWarning, [mbok], 0);
Exit;
end;
end;
end;
try
XLBook := XL.WorkBooks.Add; //새로운 페이지 생성
XLBook.WorkSheets[1].Name := Title;
XLBook.WorkSheets[Title].Range['A1'].Value :='처리일자 ' ;
XLBook.WorkSheets[Title].Range['B1'].Value := DATETOSTR((DATETIMEPICKER1.DATE)) ;
XLBook.WorkSheets[Title].Range['E1'].Value :='제 품 출 고 현 황 ' ;
XL.Visible := True;
i := 1; si := 0;
k := 0; sj := 0;
t := 0 ;
for si := 0 to colCount - 1 do
begin
if si <= 25 then
begin
CH := CHAR(65 + t) ;
CHA := CH + '2' ;
end
else
begin
p := strtofloat(formatfloat('#,##0',si));
if p-int(p/26)*26 =0 then t := 0 ;
k := strtoint(formatfloat('##0',int( p/26)));
ACH := CHAR(64+K);
CH := CHAR(65 + t ) ;
CHA := ACH + CH + '2' ;
end;
XLBook.WorkSheets[Title].Range[CHA].Value := Cells[si,0] ;
t := t + 1 ;
end;
t := 0 ;
for si := 0 to colCount - 1 do
begin
if si <= 25 then
begin
CH := CHAR(65 + t) ;
CHA := CH ;
end
else
begin
p := strtofloat(formatfloat('#,##0',si));
if p-int(p/26)*26 =0 then t := 0 ;
k := strtoint(formatfloat('##0',int( p/26)));
ACH := CHAR(64+K);
CH := CHAR(65 + t ) ;
CHA := ACH + CH ;
end;
t := t + 1 ;
for sj := 1 to RowCount - 1 do
XLBook.WorkSheets[Title].Range[CHA+IntToStr(sj+2)].Value := Cells[si,sj] ;
end;
XLBook.WorkSheets[Title].Range['A1', 'A1'].Select;
XL.Selection.Columns.AutoFit;
finally
XLBook := UnAssigned;
XL := UnAssigned;
end;
end;
end;