Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-10

StringGrid SaveToCSV should consider column visibility

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alexsander Rosa

I've managed to modify Grids.pas (SaveToCSVStream, line 10452) for the headers:

* for i := 0 to ColCount-1 do begin*
* c := ColumnFromGridColumn(i);*
* if c=nil then*
* HeaderL.Add(Cells[i, 0])*
* else*
* if c.Visible then*
* HeaderL.Add(c.Title.Caption);*
* end;*

But the other "IF" for the data did not work:

* for i:=StartRow to RowCount-1 do begin*
* c := ColumnFromGridColumn(i);*
* if c nil then*
* if not c.Visible then Continue;*
* Rows[i].StrictDelimiter := False; //force quoting of strings that contain whitespace or Delimiter*
* Rows[i].Delimiter:=ADelimiter;*
* Lines.Add(Rows[i].DelimitedText);*
* end;*

Any ideas?

Atenciosamente, Alexsander da Rosa -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20121015/51730920/attachment.html>

Reply by email

Alexsander Rosa
to Alexsander Rosa

Ok, the second "for" is about the Rows, not the Columns (duh). And the "Rows[i]" does not know about visibility.
Maybe a hand-made FOR to create the line is needed?

2012/10/15 Alexsander Rosa

Show quoted text 32 lines
I've managed to modify Grids.pas (SaveToCSVStream, line 10452) for the headers: * for i := 0 to ColCount-1 do begin* * c := ColumnFromGridColumn(i);* * if c=nil then* * HeaderL.Add(Cells[i, 0])* * else* * if c.Visible then* * HeaderL.Add(c.Title.Caption);* * end;* But the other "IF" for the data did not work: * for i:=StartRow to RowCount-1 do begin* * c := ColumnFromGridColumn(i);* * if c nil then* * if not c.Visible then Continue;* * Rows[i].StrictDelimiter := False; //force quoting of strings that contain whitespace or Delimiter* * Rows[i].Delimiter:=ADelimiter;* * Lines.Add(Rows[i].DelimitedText);* * end;* Any ideas? -- Atenciosamente, Alexsander da Rosa
Atenciosamente, Alexsander da Rosa -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20121015/76082fe0/attachment-0001.html>

Reply by email

Alexsander Rosa
to Alexsander Rosa

Please try this one:
- adds soVisibleOnly to SaveOptions
- with soVisibleOnly it checks the visibility
- without soVisibleOnly it works as before

Atenciosamente, Alexsander da Rosa -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20121015/f768ae64/attachment-0001.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: grids.pas.gz Type: application/x-gzip Size: 73823 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20121015/f768ae64/attachment-0001.bin>

Reply by email

Alexsander Rosa
to Juha Manninen

Patch attached.

2012/10/15 Juha Manninen

Show quoted text 8 lines
No, you must create a patch. http://wiki.lazarus.freepascal.org/Creating_A_Patch It helps to look at your changes and (possibly) apply them. Juha
Atenciosamente, Alexsander da Rosa -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20121015/79969121/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: grids.patch Type: application/octet-stream Size: 2231 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20121015/79969121/attachment.obj>

Reply by email