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):||6 November 2016|
|PDF File Size:||14.63 Mb|
|ePub File Size:||1.32 Mb|
|Price:||Free* [*Free Regsitration Required]|
Exporting can be done this way, but you can also use tstringlist. If you dont have a recordset, you have to iterate your dataset and write excel accesing cells. I’m just curious if that’s the best way to do it That’s why I use a dbGrid CSV from a text file into a record structure 7. If you want a fast export of raw data, just export your exprot ADODataset.
I need to export the contents of a dbGrid to a CSV file. Next; end; finally Stream. All are very good points Okay I will go have a look at that.
How to export data in DBGrid to excel – Delphi Pages Forums
Quote Sergio Gonzalez wrote: CSV File Access I have the feeling that I’m reinventing the wheel Or directly write to file with AssignFile etc. Email Required, but never shown. Otherwise it may be simpler to use the csv approach which I gave in that question.
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. Sign up using Email and Password.
The ‘try’ is in the wrong place, though. As the DBGrid might have a different set of fields then the original resultset you need to access these.
Tue, 24 Aug Thanks for the procedure! I did this procedure and so far it works fine.
Sign up using Facebook. Post as a guest Name. No’amNewman depending on the datataypes the csv approach might give more trouble in convertions e. Sergio Gonzale Delphi Developer. I will save it for future use.
dbgrid to CSV – delphi
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. Sun, 29 Aug FieldCount – 1 delphk begin s: There’s hits on a Google search for “delphi export dbgrid excel”.
I suggest you start using these, then if you have specific questions about code parts not working, post them here. Do not export the DBGrid, export the dataset stackoverflow. In order to use the variant array approach, you have to know how many rows you have in the query. EnableControls can raise an exception since it causes the screen to update, indirectly.
It is working by using Tfilestream component procedure TForm2. TObject ; var Lista: FieldName ; end; s: TObject ; var Stream: Agustin Seifert 1, bdgrid FieldCount – 1 do begin sTemp: I’m afraid I don’t undestand this point.