Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Базы";
Текущий архив: 2002.01.31;
Скачать: [xml.tar.bz2];

Вниз

Связь Delphi с Exel   Найти похожие ветки 

 
Вячеслав   (2001-12-24 18:28) [10]

Вот еще в архивах нашел обратную процедуру, может пригодиться
Sending data from Excel

This is done in the following procedure :

procedure TForm1.BitBtnFromExcelOnClick(Sender: TObject);
var
WorkBk : _WorkBook;
WorkSheet : _WorkSheet;
K, R, X, Y : Integer;
IIndex : OleVariant;
RangeMatrix : Variant;
NomFich : WideString;
begin
NomFich := ‘C:\MyDirectory\NameOfFile.xls’;
IIndex := 1;
XLApp.Connect;
// Open the Excel File
XLApp.WorkBooks.Open(NomFich,EmptyParam,EmptyParam,EmptyParam,EmptyParam, EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,0);
WorkBk := XLApp.WorkBooks.Item[IIndex];
WorkSheet := WorkBk.WorkSheets.Get_Item(1) as _WorkSheet;
// In order to know the dimension of the WorkSheet, i.e the number of rows and the
// number of columns, we activate the last non-empty cell of it
WorkSheet.Cells.SpecialCells(xlCellTypeLastCell,EmptyParam).Activate;
// Get the value of the last row
X := XLApp.ActiveCell.Row;
// Get the value of the last column
Y := XLApp.ActiveCell.Column;
// Define the number of the columns in the TStringGrid
GenericStringGrid.ColCount := Y;
// Assign the Variant associated with the WorkSheet to the Delphi Variant Matrix
RangeMatrix := XLApp.Range["A1",XLApp.Cells.Item[X,Y]].Value;
// Quit Excel and Disconnect the Server
XLApp.Quit;
XLApp.Disconnect;
// Define the loop for filling in the TStringGrid
K := 1;
repeat
for R := 1 to Y do
GenericStringGrid.Cells[(R - 1),(K - 1)] := RangeMatrix[K,R];
Inc(K,1);
GenericStringGrid.RowCount := K + 1;
until
K > X;
// Unassign the Delphi Variant Matrix
RangeMatrix := Unassigned;
end;



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

Форум: "Базы";
Текущий архив: 2002.01.31;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.44 MB
Время: 0.005 c
3-99895
sergeyh@ukrref.uz.gov.ua
2001-12-28 12:02
2002.01.31
Присечение подбора пароля SysDBA


1-99938
дикое Кенгуру
2002-01-06 06:46
2002.01.31
Как вставить в TRichEdit такоеже выпадающее меню как в TEdit ? Чтобы не писать своё и не делать мартышкин труд.


3-99849
Роман_
2001-12-26 10:59
2002.01.31
Отключить триггеры InterBase ?


1-99979
dimonf
2002-01-14 16:44
2002.01.31
Вопрос, как маштабировати и просматривать график.


6-100035
митя
2001-11-08 18:08
2002.01.31
Импорт данных из Excel-я в Delphi





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский