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: Kigazragore Gokree
Country: Qatar
Language: English (Spanish)
Genre: Medical
Published (Last): 13 December 2015
Pages: 241
PDF File Size: 2.87 Mb
ePub File Size: 16.36 Mb
ISBN: 471-6-11538-540-3
Downloads: 70594
Price: Free* [*Free Regsitration Required]
Uploader: Malataur

If you dont have a recordset, you have to iterate your dataset and write excel accesing cells. Mon, 23 Aug Exporting can be done this way, but you can also use tstringlist. I too was going to give the reference that Bummi gave.

All are very good points Sign up using Email and Password. By clicking “Post Your Answer”, dbgrif 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. So I made it last so that Lista doesn’t leak if it does raise an error. Paul Scot Delphi Developer.

Sign up using Facebook. As the DBGrid might have a different set of fields then the original resultset you need to access these. FieldName ; for I: FieldName ; end; s: Tue, 24 Aug Post 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. I would write a generic procedure taking the dbgrid as a parameter and then follow the properties to retrieve header and data.


EnableControls can raise an exception since it causes the screen to update, indirectly. The ‘try’ is in the wrong place, though.

I did this procedure and so far it works fine. Okay I will go have a look at that.

How to export data in DBGrid to excel – Delphi Pages Forums

Or directly write to file with AssignFile etc. It is working by using Tfilestream component procedure TForm2. Rich Wernin Delphi Developer. Stack Overflow works best with JavaScript enabled. Post as a guest Name.

The downside of your approach is that its not reusable, IMO a better route is to have a ddelphi you can use to handle it. And bummi’s right; if at all possible export the underlying dataset. There’s hits on a Google search for “delphi export dbgrid excel”.

In order to use the variant array approach, you have to know how many rows you have in the query. Do not export the DBGrid, dbgrkd the dataset stackoverflow. FieldCount – 1 do begin sTemp: FieldCount – 1 do begin s: Any help will be appreciated.

Reproduced Delphi DBGrid derived Excel method

No’amNewman depending on the datataypes the csv approach might give more trouble in convertions e. And if We want export an ClientDataset to Excel then what we do?


No, his code takes that into account: Email Required, but never shown. FieldCount – 1 do begin S: 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.

Other Threads

That’s why I use a dbGrid Quote Sergio Gonzalez wrote: If you want a fast export of raw data, just export your recordset ADODataset. TObject ; var Lista: I need to export the contents of a dbGrid to a CSV file.

Next; end; finally Stream. I’m just curious if that’s exporr best way to do it By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Sign up or log in Sign up using Google.

I will save it for future use. Otherwise it may be simpler to use the csv approach which I gave in that question.

CSV File Access Sun, 29 Aug I suggest you start using these, then if you have specific questions about code parts not working, post them here.