db to .xls lazarus / 16-Databases ---------------------------------------------------------------------- flori · 2021-02-15 07:44 Hi everyone! This small program can export all dbgrid (db) content. How to solve to export only certain (what I want) columns? for example:  do not export the last column. Thank you. ---------------------------------------------------------------------- wp · 2021-02-15 09:17 I cannot run your demo because an error "Unsupported on-disk structure for file" is reported. But if you don't want to export the entire table you must add the fields to be exported to the ExportFields of the exporter. Either in the Object Inspector when the dataset is open, or later at runtime by calling Exporter.ExportFields.AddField(fieldname). ---------------------------------------------------------------------- balazsszekely · 2021-02-15 09:23 Create a new query for export(zqExport for example). Modify zqExport.SQL, add the fields you whish to export: Code: MySQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i select lb.calium, lb."CACO3%", lb."ION%" from labor lb PS: @wp was faster. His solution does not require a new query. Use whichever method you find easier. ---------------------------------------------------------------------- flori · 2021-02-15 10:25 Thanks. Do you know how can I change not be the same dbrgird cells with xls? or start on another line? what would be the best solution? ---------------------------------------------------------------------- flori · 2021-02-15 14:38 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     var Exp: TFPSExport; ExpSettings: TFPSExportFormatSettings; TheDate: TDateTime; begin    ZQuery1.First; Exp := TFPSExport.Create(nil); ExpSettings := TFPSExportFormatSettings.Create(true); try ExpSettings.ExportFormat := efXLS; ExpSettings.HeaderRow := true;  Exp.FormatSettings := ExpSettings; Exp.Dataset:=ZQuery1; Exp.FileName := 'export\labor.xls';  Exp.Execute; finally Exp.Free; ExpSettings.Free; end ---------------------------------------------------------------------- wp · 2021-02-15 15:54 I don't understand your requirement. You want the cells "CALIUM", "CACO3%" and "ION%" to be included in the xls file? In this case you must set ExpSettings.HeaderRow to true, and your screenshot shows exactly what you will get (you cannot replace the header names "A", "B", "C" in the spreadsheet). You want the cells "CALIUM", "CACO3%" and "ION%" NOT to be included in the xls file?  In this case you must set ExpSettings.HeaderRow to false, and the export will skip the header row of the dbgrid. ---------------------------------------------------------------------- flori · 2021-02-15 16:16 (you cannot replace the header names "A", "B", "C" in the spreadsheet). I didn't know it couldn't be. ---------------------------------------------------------------------- flori · 2021-02-15 16:19 I wanted to replace it, because we use accented letters (accented characters) for example "talaj állapota/űú", etc ---------------------------------------------------------------------- wp · 2021-02-15 16:33 Quote from: flori on February 15, 2021, 05:16:48 pm(you cannot replace the header names "A", "B", "C" in the spreadsheet). I didn't know it couldn't be. The FPSpreadsheet grid has an event in which the column header captions can be replaced, but this is not stored in the xls file (AFAIK, Excel does not allow to change the A,B,C headers. ---------------------------------------------------------------------- flori · 2021-02-15 18:23 ok, thank you.