M
mjself
Unregistered / Unconfirmed
GUEST, unregistred user!
我要从一个query中生成一个 EXCEL CSV文件(实际上就是一个逗号分隔的文本文件)
下面这段程序中当query1中的记录数不多时,程序通过
当query1中的记录数达500左右时,出现 TRichEdit插入错误
是不是TRichedit.lines可存入的文本行数有限制?
怎么才能去掉这个限制?
mem := TRichEdit.Create(Self);
mem.PlainText := True;
mem.parent := self;
try
while not Query1.EOF do
with Query1 do
begin
Price:= FieldByName('PRICE').ASFloat*(100-FieldByName('DISCOUNT').AsFloat)/100;
Qty:=FieldByName('SBQTY').AsInteger;
LineStr := Trim(FieldByName('CoCode').AsString)+','; // 1
LineStr := LineStr + FieldByName('SBNO').AsString+','; //2
LineStr := LineStr + DateToStr(FieldByName('SBDATE').AsDateTime)+',';//3
LineStr := LineStr + 'FALSE,,,';//4
LineStr := LineStr + 'FALSE,,,,,,,,';//7
LineStr := LineStr + FieldByName('COINV').AsString+',,,'; //15
LineStr := LineStr + FieldByName('COINV').AsString+','; //18=#15+30 ???
LineStr := LineStr + '0'+','; //19
LineStr := LineStr + DateToStr(FieldByName('SBDATE').AsDateTime)+',,,';//20=#3
LineStr := LineStr + Trim(Ed_AR.Text)+',,,,,,'; // 23
LineStr := LineStr + FieldByName('BOITEM').AsString+',,'; //29
LineStr := LineStr + IntToStr(Qty)+',,'; //31
LineStr := LineStr + FieldByName('PMODEL').AsString+',,,'; //33
LineStr := LineStr + Trim(Ed_GL.Text)+','; // 36
LineStr := LineStr + FormatFloat('0.00',Price)+','; // 37
LineStr := LineStr + '1'+','; //38
LineStr := LineStr + '-'+FormatFloat('0.00',Price*Qty)+',,,'; // 39
LineStr := LineStr + Trim(Ed_Period.Text)+','; // 42
LineStr := LineStr + IntToStr(ID); //43
mem.Lines.Append(LineStr);
ID:=ID+1;
Query1.Next;
ProgressBar.Position := ProgressBar.Position + 1;
end;
mem.Lines.SaveToFile(DpsOutDir + '/SBOUT.CSV');
Mem.Free;
StatusBar.SimpleText := 'ok';
except
mem.Lines.Clear;
StatusBar.SimpleText := 'fail';
end;
下面这段程序中当query1中的记录数不多时,程序通过
当query1中的记录数达500左右时,出现 TRichEdit插入错误
是不是TRichedit.lines可存入的文本行数有限制?
怎么才能去掉这个限制?
mem := TRichEdit.Create(Self);
mem.PlainText := True;
mem.parent := self;
try
while not Query1.EOF do
with Query1 do
begin
Price:= FieldByName('PRICE').ASFloat*(100-FieldByName('DISCOUNT').AsFloat)/100;
Qty:=FieldByName('SBQTY').AsInteger;
LineStr := Trim(FieldByName('CoCode').AsString)+','; // 1
LineStr := LineStr + FieldByName('SBNO').AsString+','; //2
LineStr := LineStr + DateToStr(FieldByName('SBDATE').AsDateTime)+',';//3
LineStr := LineStr + 'FALSE,,,';//4
LineStr := LineStr + 'FALSE,,,,,,,,';//7
LineStr := LineStr + FieldByName('COINV').AsString+',,,'; //15
LineStr := LineStr + FieldByName('COINV').AsString+','; //18=#15+30 ???
LineStr := LineStr + '0'+','; //19
LineStr := LineStr + DateToStr(FieldByName('SBDATE').AsDateTime)+',,,';//20=#3
LineStr := LineStr + Trim(Ed_AR.Text)+',,,,,,'; // 23
LineStr := LineStr + FieldByName('BOITEM').AsString+',,'; //29
LineStr := LineStr + IntToStr(Qty)+',,'; //31
LineStr := LineStr + FieldByName('PMODEL').AsString+',,,'; //33
LineStr := LineStr + Trim(Ed_GL.Text)+','; // 36
LineStr := LineStr + FormatFloat('0.00',Price)+','; // 37
LineStr := LineStr + '1'+','; //38
LineStr := LineStr + '-'+FormatFloat('0.00',Price*Qty)+',,,'; // 39
LineStr := LineStr + Trim(Ed_Period.Text)+','; // 42
LineStr := LineStr + IntToStr(ID); //43
mem.Lines.Append(LineStr);
ID:=ID+1;
Query1.Next;
ProgressBar.Position := ProgressBar.Position + 1;
end;
mem.Lines.SaveToFile(DpsOutDir + '/SBOUT.CSV');
Mem.Free;
StatusBar.SimpleText := 'ok';
except
mem.Lines.Clear;
StatusBar.SimpleText := 'fail';
end;