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):||17 May 2009|
|PDF File Size:||8.48 Mb|
|ePub File Size:||5.13 Mb|
|Price:||Free* [*Free Regsitration Required]|
I need to export the contents of a dbGrid to a CSV file. Thanks for the procedure! Sun, 29 Aug Otherwise it may be simpler to use the csv approach which I gave in that question. Mon, 23 Aug It is working by using Tfilestream component procedure TForm2.
Alexander 3, 6 13 Or directly write to file with AssignFile etc. The downside of your approach is that expogt not reusable, IMO a better route is to have a procedure you can use to handle it. Next; end; finally Stream. FieldCount – 1 do begin sTemp: I have the feeling that I’m reinventing the wheel TObject ; var Stream: No, his code takes that into account: Okay I will go have a look at that.
Dgrid suggest you start using these, then if you have specific questions about code parts not working, post them here. FieldName ; for I: If you dont have a recordset, you have to iterate your dataset and write excel accesing cells. Email Required, but never shown.
The ‘try’ is in the wrong place, though. CSV File Access TObject ; var Lista: FieldName ; end; s: I did this procedure and so far it works fine. If you want a fast export of raw data, just export your recordset ADODataset. All delpih very good points I’m just curious if that’s the best way to do it I will save it for future use.
And if We want export an ClientDataset to Excel then what we do? Rich Wernin Delphi Developer. EnableControls can raise an exception since it causes the screen to update, indirectly.
: export a TDBGrid to excel without OLE?
CSV from a text file into a record structure 7. FieldCount – 1 do begin s: As the DBGrid might have a different set of fields then the original resultset you need to access these. There’s hits on a Google search for “delphi export dbgrid excel”. In order to use the variant array approach, you have dbgfid know how many rows you have in the query.
Exporting can be done this way, but you can also use tstringlist. Tue, 24 Aug Any help will be appreciated. Sergio Gonzale Delphi Developer.
Reproduced Delphi DBGrid derived Excel method
And bummi’s right; if at all possible export the underlying dataset. That’s why I use a dbGrid Do not export the DBGrid, export the dataset stackoverflow.