11-01-21, 01:57 AM
السلام عليكم
كل عام وانتم بخير
اتمني ان تكونوا بخير حال وافضل صحة
لدي مشروع فيجوال بيسك مرتبط بقاعدة بيانات Access
لدي Form به DataGridView اريد تصدير البيانات التي به الى ملف اكسيل عن طريق مربع الحوار حفظ الى Save as
لتحديد مكان الحفظ
انا استخدم هذا الكود
وكذلك اريد ربط عملية التصدير هذه بــ ProgressBar
ارجوا ان اجد ضالتي لديكم
كفانا الله واياكم شر الوباء
سبحان الله وبحمده سبحان الله العظيم
كل عام وانتم بخير
اتمني ان تكونوا بخير حال وافضل صحة
لدي مشروع فيجوال بيسك مرتبط بقاعدة بيانات Access
لدي Form به DataGridView اريد تصدير البيانات التي به الى ملف اكسيل عن طريق مربع الحوار حفظ الى Save as
لتحديد مكان الحفظ
انا استخدم هذا الكود
كود :
Dim MsExcel = CreateObject("Excel.Application")
MsExcel.Workbooks.Add()
For i As Integer = 0 To 3
Next
MsExcel.Cells(0 + 1).Value = DataGridView1.Columns(0).HeaderText
MsExcel.Cells(1 + 1).Value = DataGridView1.Columns(2).HeaderText
MsExcel.Cells(2 + 1).Value = DataGridView1.Columns(3).HeaderText
MsExcel.Cells(3 + 1).Value = DataGridView1.Columns(4).HeaderText
MsExcel.Cells(4 + 1).Value = DataGridView1.Columns(5).HeaderText
MsExcel.Cells(5 + 1).Value = DataGridView1.Columns(10).HeaderText
MsExcel.Cells(6 + 1).Value = DataGridView1.Columns(12).HeaderText
MsExcel.Cells(7 + 1).Value = DataGridView1.Columns(37).HeaderText
For j As Integer = 0 To DataGridView1.Rows.Count - 1
MsExcel.Columns.Font.Name = "Times New Roman"
MsExcel.Cells(j + 2, 1).Value = DataGridView1.Rows(j).Cells(0).Value
MsExcel.Cells(j + 2, 2).Value = DataGridView1.Rows(j).Cells(2).Value
MsExcel.Cells(j + 2, 3).Value = DataGridView1.Rows(j).Cells(3).Value
MsExcel.Cells(j + 2, 4).Value = DataGridView1.Rows(j).Cells(4).Value
MsExcel.Cells(j + 2, 5).Value = DataGridView1.Rows(j).Cells(5).Value
MsExcel.Cells(j + 2, 6).Value = DataGridView1.Rows(j).Cells(10).Value
MsExcel.Cells(j + 2, 7).Value = DataGridView1.Rows(j).Cells(12).Value
MsExcel.Cells(j + 2, 8).Value = DataGridView1.Rows(j).Cells(37).Value
Next
MsExcel.Visible = True
وكذلك اريد ربط عملية التصدير هذه بــ ProgressBar
ارجوا ان اجد ضالتي لديكم
كفانا الله واياكم شر الوباء
سبحان الله وبحمده سبحان الله العظيم