كود التصديل لاكسيل + الطباعة عن طريق الاكسيل
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
'تصدير(لاكسيل)
Dim EOpject As Object
Dim ENew As Object
Dim EWork As Object
'----------------------
Dim I, N, nog As Integer
'---------------------------------------------------
nog = DataGridView1.Rows.Count
EOpject = CreateObject("Excel.Application")
ENew = EOpject.Workbooks.open("مسار الملف واسمة", , , , "كلمة السر")
EWork = ENew.Worksheets("اسم الصفة")
'----------------------------------------------------
'نقل بيانات تيكيست بوك او كمبو بوكس الى الاكسيل
EWork.Cells(3, 2).Value = TextBox1.Text
EWork.Cells(4, 2).Value = ComboBox1.Text
EWork.Cells(3, 7).Value = DateTimePicker1.Text
EWork.Cells(4, 7).Value = TextBox2.Text
EWork.Cells(6, 1).Value = TextBox5.Text
'نقل محتوايات الداتا جريد فيو الى الاكسيل
For I = 0 To DataGridView1.RowCount - 1
For N = 1 To Me.DataGridView1.ColumnCount - 1
EWork.Cells(I + 8, N).Value = DataGridView1.Rows(I).Cells(N).Value
Next
Next
EWork.Cells(7 + nog, 1).Value = TextBox3.Text
EWork.Cells(7 + nog, 2).Value = TextBox4.Text
EWork.Cells(7 + nog, 3).Value = "الاجمالى"
EWork.Cells(9 + nog, 3).Value = "توقيع المحاسب"
EWork.Cells(9 + nog, 5).Value = "توقيع المراجع"
'لظهور الاكسيل او عدم الظهور***********************
EOpject.Visible = False
'لطباعة الصفحة المحددة
EWork.PrintOut(From:=1, Copies:=1, Collate:=True)
EWork = Nothing
ENew = Nothing
EOpject.Quit()
EOpject = Nothing
GC.Collect()
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
'تصدير(لاكسيل)
Dim EOpject As Object
Dim ENew As Object
Dim EWork As Object
'----------------------
Dim I, N, nog As Integer
'---------------------------------------------------
nog = DataGridView1.Rows.Count
EOpject = CreateObject("Excel.Application")
ENew = EOpject.Workbooks.open("مسار الملف واسمة", , , , "كلمة السر")
EWork = ENew.Worksheets("اسم الصفة")
'----------------------------------------------------
'نقل بيانات تيكيست بوك او كمبو بوكس الى الاكسيل
EWork.Cells(3, 2).Value = TextBox1.Text
EWork.Cells(4, 2).Value = ComboBox1.Text
EWork.Cells(3, 7).Value = DateTimePicker1.Text
EWork.Cells(4, 7).Value = TextBox2.Text
EWork.Cells(6, 1).Value = TextBox5.Text
'نقل محتوايات الداتا جريد فيو الى الاكسيل
For I = 0 To DataGridView1.RowCount - 1
For N = 1 To Me.DataGridView1.ColumnCount - 1
EWork.Cells(I + 8, N).Value = DataGridView1.Rows(I).Cells(N).Value
Next
Next
EWork.Cells(7 + nog, 1).Value = TextBox3.Text
EWork.Cells(7 + nog, 2).Value = TextBox4.Text
EWork.Cells(7 + nog, 3).Value = "الاجمالى"
EWork.Cells(9 + nog, 3).Value = "توقيع المحاسب"
EWork.Cells(9 + nog, 5).Value = "توقيع المراجع"
'لظهور الاكسيل او عدم الظهور***********************
EOpject.Visible = False
'لطباعة الصفحة المحددة
EWork.PrintOut(From:=1, Copies:=1, Collate:=True)
EWork = Nothing
ENew = Nothing
EOpject.Quit()
EOpject = Nothing
GC.Collect()
End Sub