큰꼼의 세상

procedure SaveToCSVFile(sGrid: TStringGrid; sCsvFile:string);
var
    i: Integer;
    sLst: TStringList;
begin
    sLst:=TStringList.Create;

    try
        begin
            for i:=0 to sGrid.RowCount -1 do
            begin
                sLst.Add(sGrid.Rows[i].CommaText);
            end;

            sLst.SaveToFile(sCsvFile);
        end
        finally
            sLst.Free;
        end;
end;

procedure LoadFromCSVFile(sGrid: TStringGrid; sCsvFile:string);
var
    i: Integer;
    sLst: TStringList;
    sCols: TStringList;
begin
    if not FileExists(sCSVFile)then
    begin
        Exit;
    end;

    sLst:=TStringList.Create;
    sCols:=TStringList.Create;

    try
    begin
        sLst.LoadFromFile(sCSVFile);
        sGrid.RowCount:=sLst.Count;

        for i:=0 to sLst.Count -1 do
        begin
            sCols.CommaText:=sLst.Strings[i];
            if sCols.Count>sGrid.ColCount then
            begin
                sGrid.ColCount:=sCols.Count;
            end;

            sGrid.Rows[i].Assign(sCols);
        end
    end
    finally
        sLst.Free;
        sCols.Free;
    end;
end;

출처 : http://cbuilder.borlandforum.com/impboard/impboard.dll?action=read&db=bcb_tip&no=1092