[Lazarus-es] Cargar archivo csv en una stringgrid

Omega ( jcuello ) jcuello en artextrading.com
Mar Ago 2 07:51:32 CEST 2011


Hola, no se si un TStringGrid tiene la opción, pero todos los 
componentes derivados de TStrings tienen para pasar y recoger los items 
a una cadena string separada por un delimitador. Además tiene un 
loadfromfile y savefromfile .... combinando estos métodos tiene que ser 
muy sencillo.

(sacado de la documentación online de free pascal)
type TStrings = class(TPersistent 
<http://www.freepascal.org/docs-html/rtl/classes/tpersistent.html>)
procedure LoadFromFile 
<http://www.freepascal.org/docs-html/rtl/classes/tstrings.loadfromfile.html>();virtual;            
// Insert a string and associated object in the list.
procedure SaveToFile 
<http://www.freepascal.org/docs-html/rtl/classes/tstrings.savetofile.html>();virtual               
// Move a string from one place in the list to another.
property Delimiter 
<http://www.freepascal.org/docs-html/rtl/classes/tstrings.delimiter.html>: 
Char; [rw] // Delimiter character used in DelimitedText 
<http://www.freepascal.org/docs-html/rtl/classes/tstrings.delimitedtext.html>. 

property DelimitedText 
<http://www.freepascal.org/docs-html/rtl/classes/tstrings.delimitedtext.html>: 
String; [rw] // Get or set all strings in the list in a delimited form.
property StrictDelimiter 
<http://www.freepascal.org/docs-html/rtl/classes/tstrings.strictdelimiter.html>: 
Boolean; [rw]       // Should only the delimiter character be considered 
a delimiter
property QuoteChar 
<http://www.freepascal.org/docs-html/rtl/classes/tstrings.quotechar.html>: 
Char; [rw]                // Quote character used in DelimitedText 
<http://www.freepascal.org/docs-html/rtl/classes/tstrings.delimitedtext.html> 
.
property CommaText 
<http://www.freepascal.org/docs-html/rtl/classes/tstrings.commatext.html>: 
String; [rw]              // Capacity of the list, i.e. number of 
strings that the list can currently hold before it tries to expand.

Espero te sirva, un saludo.


El 29/07/11 18:24, Gustavo Cruz Martínez escribió:
> Buenas tardes amigos,
>
> Me gustaría saber cuál es la forma de cargar, en tiempo de ejecución, 
> un archivo delimitado por como.
>
> Gracias de Antemano por vuestro tiempo
>
>
> Gustavo Cruz
>
> _______________________________________________
> Lazarus-es mailing list
> Lazarus-es en lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus-es
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus-es/attachments/20110802/3ed3a66f/attachment-0002.html>


More information about the Lazarus-es mailing list