شرح comment importer des classeurs excel vers une base de données delphi - منتديات الجلفة لكل الجزائريين و العرب

العودة   منتديات الجلفة لكل الجزائريين و العرب > منتديات التقنية > منتدى البرمجة

منتدى البرمجة كل ما يتعلق بلغات البرمجة، فيجوال بيسيك , سي ++ , دلفي , أكسيس , جافا , هتمل...

في حال وجود أي مواضيع أو ردود مُخالفة من قبل الأعضاء، يُرجى الإبلاغ عنها فورًا باستخدام أيقونة تقرير عن مشاركة سيئة ( تقرير عن مشاركة سيئة )، و الموجودة أسفل كل مشاركة .

آخر المواضيع

comment importer des classeurs excel vers une base de données delphi

إضافة رد
 
أدوات الموضوع انواع عرض الموضوع
قديم 2016-03-07, 13:16   رقم المشاركة : 1
معلومات العضو
zaki4482
عضو فعّال
 
الصورة الرمزية zaki4482
 

 

 
إحصائية العضو










16 comment importer des classeurs excel vers une base de données delphi

comment importer une classeur ( table excel ) vers une base de données delphi









 


رد مع اقتباس
قديم 2016-03-08, 09:42   رقم المشاركة : 2
معلومات العضو
zaki4482
عضو فعّال
 
الصورة الرمزية zaki4482
 

 

 
إحصائية العضو










Rosiecheeks Importer les données excel vers string grid

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls, Buttons,ComObj;

type
TForm3 = class(TForm)
BitBtn1: TBitBtn;
StringGrid1: TStringGrid;
SpeedButton1: TSpeedButton;
procedure BitBtn1Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;

var
Form3: TForm3;

implementation

uses Unit1;

{$R *.dfm}
function Xls_To_StringGrid(AGrid: TStringGrid; AXLSFile: string): Boolean;
const
xlCellTypeLastCell = $0000000B;
var
XLApp, Sheet: OLEVariant;
RangeMatrix: Variant;
x, y, k, r: Integer;
begin
Result := False;
// Create Excel-OLE Object
XLApp := CreateOleObject('Excel.Application');
try
// Hide Excel
XLApp.Visible := False;
// Open the Workbook
XLApp.Workbooks.Open(AXLSFile);
// Sheet := XLApp.Workbooks[1].WorkSheets[1];
Sheet := XLApp.Workbooks[ExtractFileName(AXLSFile)].WorkSheets[1];
// 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
Sheet.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;
// Set Stringgrid's row &col dimensions.
AGrid.RowCount := x;
AGrid.ColCount := y;
// Assign the Variant associated with the WorkSheet to the Delphi Variant
RangeMatrix := XLApp.Range['A1', XLApp.Cells.Item[X, Y]].Value;
// Define the loop for filling in the TStringGrid
k := 1;
repeat
for r := 1 to y do
AGrid.Cells[(r - 1), (k - 1)] := RangeMatrix[K, R];
Inc(k, 1);
AGrid.RowCount := k + 1;
until k > x;
// Unassign the Delphi Variant Matrix
RangeMatrix := Unassigned;

finally
// Quit Excel
if not VarIsEmpty(XLApp) then
begin
// XLApp.DisplayAlerts := False;
XLApp.Quit;
XLAPP := Unassigned;
Sheet := Unassigned;
Result := True;
end;
end;
end;

procedure TForm3.BitBtn1Click(Sender: TObject);
begin
if Xls_To_StringGrid(StringGrid1, 'D:\Table1.xls') then
ShowMessage('Table has been exported!');


end;








الصور المرفقة
نوع الملف: jpg form delphi.jpg‏ (117.6 كيلوبايت, المشاهدات 16)

رد مع اقتباس
إضافة رد

الكلمات الدلالية (Tags)
delphi, excel


تعليمات المشاركة
لا تستطيع إضافة مواضيع جديدة
لا تستطيع الرد على المواضيع
لا تستطيع إرفاق ملفات
لا تستطيع تعديل مشاركاتك

BB code is متاحة
كود [IMG] متاحة
كود HTML معطلة

الانتقال السريع

الساعة الآن 07:24

المشاركات المنشورة تعبر عن وجهة نظر صاحبها فقط، ولا تُعبّر بأي شكل من الأشكال عن وجهة نظر إدارة المنتدى
المنتدى غير مسؤول عن أي إتفاق تجاري بين الأعضاء... فعلى الجميع تحمّل المسؤولية


2006-2024 © www.djelfa.info جميع الحقوق محفوظة - الجلفة إنفو (خ. ب. س)

Powered by vBulletin .Copyright آ© 2018 vBulletin Solutions, Inc