Hello All, Could somebody can show me a short example how to export a dbgrid to a simple text file (comma separated)? I did not find any. There is already an article explaining how to export from THTMLViewer using eDocEngine. However, it tried to solve a bit more complicated. Exporting a DBGrid to excel without OLE I develop software and about 95% of my work deals with databases. I enjoied the advantages of using Microsoft Excel.

Author: Kazrarn Shakakree
Country: Sri Lanka
Language: English (Spanish)
Genre: Medical
Published (Last): 18 March 2014
Pages: 420
PDF File Size: 2.96 Mb
ePub File Size: 13.44 Mb
ISBN: 678-1-93950-835-9
Downloads: 43692
Price: Free* [*Free Regsitration Required]
Uploader: Voodoogal

That’s why I use a dbGrid FieldName ; end; s: Paul Scot Delphi Developer. I did this procedure and so far it works fine.

FieldCount – 1 do begin sTemp: Sun, 29 Aug In order to use the variant array approach, you have to know how many rows you have in the query. Quote Sergio Gonzalez wrote: Okay I will go have a look at that. Next; end; finally Stream. No’amNewman depending on the datataypes the csv approach might give more trouble in vbgrid e.

Alexander 3, 6 13 Post as a guest Name.

FieldCount – 1 do begin S: Sign up using Email and Password. FieldCount – 1 do begin s: The ‘try’ is in the wrong place, though. I need to export the contents of a dbGrid to a CSV file.


Export contents of DBGrid to Excel or ClipBoard

CSV File Access Any help will be appreciated. I too was going to give the reference that Bummi gave. And bummi’s right; if at all possible export the underlying dataset. CSV from a text file into a record structure 7. If you dont have a recordset, you have to iterate your dataset and write excel accesing cells.

dbgrid to CSV – delphi

All are very good points Thanks for the procedure! The downside of your approach is that its not reusable, IMO a better route is to have a procedure you can use to handle it. TObject ; var Stream: There’s hits on a Google search for “delphi export dbgrid excel”. No, his code takes that into account: I have the feeling that I’m reinventing the wheel Otherwise it may be simpler to use the csv approach which I gave dbgriid that question.

Reproduced Delphi DBGrid derived Excel method

Stack Overflow works best with JavaScript enabled. Explrt Your Answer Discard By clicking “Post Your Answer”, you acknowledge that you have read our updated terms of serviceprivacy policy and cookie policyand that your continued use of the website is subject to these policies. Agustin Seifert 1, 12 Do not export the DBGrid, export the dataset stackoverflow. It is working by using Tfilestream component procedure TForm2.


Other Threads

And if We want export an ClientDataset to Excel delphu what we do? As the DBGrid might have a different set of fields then the original resultset you need to access these. Tue, 24 Aug I would write a generic procedure taking the dbgrid as a parameter and then follow the properties to retrieve header and data.

The grid is a kind of “preview” and the user can choose the order in wich the fileds will be exported, by changing the field’s order in the grid.

Sign up using Facebook. I will save it for future use.

I suggest you start using these, then if you have specific questions about code parts not working, post them here. Sergio Gonzale Delphi Developer. FieldName ; for I: Email Required, but never shown.

Exporting can be done this way, but you can also use tstringlist. TObject ; var Lista: I’m afraid I don’t undestand this point. Sign up or log in Sign up using Google. Or directly write to file with AssignFile etc.