AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Export table rows

Ein Thema von danten · begonnen am 21. Sep 2013 · letzter Beitrag vom 23. Sep 2013
Antwort Antwort
danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#1

Export table rows

  Alt 21. Sep 2013, 22:12
Datenbank: Absolute Database • Version: 1 • Zugriff über: 1
Hi all.
Now I deal with the export of table rows entry in the filter, but it is ineffective.
I need to export table rows after 200 rows repeatedly until no Table1.RecordCount = 0.
The file name would be increased by 1.
export1.csv, export2.csv ......
CSVExport = JvDBGridCSVExport
Thank you all for your ideas.
Delphi-Quellcode:
tab1.Filtered := False;
  tab1.Filter := 'Cislo_ID > 0 AND Cislo_ID < 201';
  tab1.Filtered := True;
  CSVExport.FileName := ExtractFilePath(ParamStr(0))+ 'upload/export1.csv';
  CSVExport.Separator := ';';
  CSVExport.ExportGrid;
  tab1.Filtered := False;
  tab1.Filter := 'Cislo_ID > 199 AND Cislo_ID < 401';
  tab1.Filtered := True;
  CSVExport.FileName := ExtractFilePath(ParamStr(0))+ 'upload/export2.csv';
  CSVExport.Separator := ';';
  CSVExport.ExportGrid;
  tab1.Filtered := False;
  tab1.Filter := 'Cislo_ID > 399 AND Cislo_ID < 601';
  tab1.Filtered := True;
  CSVExport.FileName := ExtractFilePath(ParamStr(0))+ 'upload/export3.csv';
  CSVExport.Separator := ';'
  CSVExport.ExportGrid;
Daniel
  Mit Zitat antworten Zitat
danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#2

AW: Export table rows

  Alt 22. Sep 2013, 11:57
Delphi-Quellcode:
  x := 0;
  repeat;
  y := Random(200);
for i := y tab1.RecordCount -1 do
begin
  tab1.Filtered := False;
  tab1.Filter := 'Cislo_ID > '+ QuotedStr(x) + ' AND Cislo_ID < '+ QuotedStr(y);
  tab1.Filtered := True;
  CSVExport.FileName := ExtractFilePath(ParamStr(0))+ 'upload/export'+IntToStr(x+1)+'.csv';
  CSVExport.Separator := ';';
  CSVExport.ExportGrid;
  until x = 0;
export1.csv = 200 lines (0 to 200)
export2.csv = 200 lines (201 to 400)
export3.csv = 200 lines (401 to 600)
export4.csv = x lines (601 to ??)
Daniel
  Mit Zitat antworten Zitat
Benutzerbild von sx2008
sx2008

Registriert seit: 15. Feb 2008
Ort: Baden-Württemberg
2.332 Beiträge
 
Delphi 2007 Professional
 
#3

AW: Export table rows

  Alt 22. Sep 2013, 14:04
Delphi-Quellcode:
const BSIZE = 200;

....
CSVExport.Separator := ';'; // moved outside of the loop because we need so set the separator only once
for i := 0 to (tab1.RecordCount div BSIZE) + 1 do
begin
  tab1.Filtered := False;
  // note: lower margin is included and upper margin is excluded
  // 0..199 (200 records)
  // 200..399 (200 records)
  tab1.Filter := 'Cislo_ID >='+ QuotedStr(i*BSIZE) + ' AND Cislo_ID < '+ QuotedStr((i+1)*BSIZE);
  tab1.Filtered := True;
  if tab1.IsEmpty then
    break; // stop export if there are no more records
  CSVExport.FileName := ExtractFilePath(ParamStr(0))+ 'upload/export'+IntToStr(i+1)+'.csv';
  CSVExport.ExportGrid;
end;
fork me on Github

Geändert von sx2008 (22. Sep 2013 um 23:50 Uhr) Grund: bugfix
  Mit Zitat antworten Zitat
danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#4

AW: Export table rows

  Alt 23. Sep 2013, 02:50
OK sx2008,
export1.csv = 732 lines
export2.csv = 221 lines
export3.csv = 221 lines
export4.csv = 221 lines
......
Daniel
  Mit Zitat antworten Zitat
Furtbichler
(Gast)

n/a Beiträge
 
#5

AW: Export table rows

  Alt 23. Sep 2013, 07:52
Why is that so? Take a look at the export files. Which Cislo-ID do they contain? I bet all is ok according to what you've told us (i.e. export1.CSV contains all recors with a Cislo-ID of 0..199).

Am I right?
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:15 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz