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.
|Published (Last):||16 September 2004|
|PDF File Size:||2.66 Mb|
|ePub File Size:||12.54 Mb|
|Price:||Free* [*Free Regsitration Required]|
Okay Dlephi will go have a look at that. Tue, 24 Aug I’m just curious if that’s the best way to do it FieldName ; end; s: EnableControls can raise an exception since it causes the screen to update, indirectly. I will save it for future use.
: export a TDBGrid to excel without OLE?
FieldCount – 1 do begin s: And bummi’s right; if at all possible export the underlying dataset. I have the feeling that I’m reinventing the wheel FieldName ; for I: Sign up or log in Sign up using Google.
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. I would write a generic procedure taking the dbgrid as a parameter and then follow the properties to retrieve header and data. That’s why I use a dbGrid Exporting can be done this way, but you can also use tstringlist.
Or directly write to file with AssignFile etc. dbgeid
delphi – Exporting data from a DBGrid to Excel – Stack Overflow
Post as a guest Name. Quote Sergio Gonzalez wrote: Tp you dont have a recordset, you have to iterate your dataset and write excel accesing cells. There’s hits on a Google search for “delphi export dbgrid excel”. Sun, 29 Aug Alexander 3, 6 13 Email Required, but never shown.
I did this procedure and so far it works fine. And if We want export an ClientDataset to Excel then what we do? Agustin Seifert 1, 12 Sign up using Email and Password.
Sign up using Facebook. As the DBGrid might have a different set of fields then the original dbgriv you need to access these. In order to use the variant array approach, you have to know how many rows you have in the query.
Export contents of DBGrid to Excel or ClipBoard
TObject ; var Stream: Next; end; finally Stream. All are very good points I suggest you start using these, then if you have specific questions about code parts not working, post them here.
FieldCount – 1 do begin S: I need to export the contents of a dbGrid to a CSV file. 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. It is working by using Tfilestream component procedure TForm2.
Mon, 23 Aug If you want a fast export of raw data, just export your recordset ADODataset.
No, his code takes that into account: Rich Wernin Delphi Developer. Do not export the DBGrid, export the dataset stackoverflow.