Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.02.13;
Скачать: CL | DM;

Вниз

копирование из буфера в Grid   Найти похожие ветки 

 
dendy   (2004-02-04 22:22) [0]

Господа,скопировал в буфер кусок из Excel. как вставить его в какой нибудь Grid (например в StringGrid, а лучше DBgrid) в соотвествующие столбцы.


 
Talla2k ©   (2004-02-04 22:46) [1]

Только тут есть ошибки(незначительные).Короче юзай!!!

procedure TForm1.PasteGrid(Grid: TStringGrid; Ignore: boolean);
// При Ignore = true происходит увел.ячеек,при false урезание
var x, y, i: integer;
str, str2: string;
begin
str := Clipboard.AsText;
i := 1;
if Length(str) > 0 then
with Grid do begin
y := Row - 1;
while (str[i] <> #0) and (i < Length(str)) do begin
inc(y);
x := Col - 1;
while (str[i] <> #10) and (str[i] <> #13) and (str[i] <> #0) and (i < Length(str)) do begin
str2 := "";
while (str[i] <> #09) and (str[i] <> #10) and (str[i] <> #13) and (str[i] <> #0) {and
(i < Length(str)) }do begin
str2 := str2 + str[i];
inc(i);
end;
inc(i);
inc(x);
if (x >= ColCount) and Ignore then ColCount := ColCount + 1;
if (y >= RowCount) and Ignore then RowCount := RowCount + 1;
if not ((x >= ColCount) or (y >= RowCount)) then Cells[x, y] := str2;
end;
while ((str[i] = #10) or (str[i] = #13)) and (i < Length(str)) do
inc(i);
end;
end;
end;


 
dendy   (2004-02-04 22:52) [2]

Вот спасибо! Все работает! счас под себя еще заточу...


 
Talla2k ©   (2004-02-05 00:34) [3]

Как заточиш, пришли мне на мыло.Посмотрю!!



Страницы: 1 вся ветка

Текущий архив: 2004.02.13;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.035 c
1-38954
Goida
2004-02-02 17:52
2004.02.13
Грязь в округлении


14-39093
ИМХО
2004-01-21 20:52
2004.02.13
XML в Delphi 5


1-38779
AlexeyITN
2004-02-03 16:04
2004.02.13
ProgressBar1 и TThread


3-38731
VID
2004-01-18 02:56
2004.02.13
К теме о странном поведении fibplus при неудачном коннекте


3-38725
Oleg_em
2004-01-22 07:09
2004.02.13
Ошибка при подключении к базе IB