منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : كيفية تصدير اعمدة محددة من الداتا قريد الي الاكسل
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
السلام عليكم اصدقائي 

كيف حالكم جميعا 

كيف يمكنني تصدير اعمده التي انا احددها عن طريق CheckBox بحيث يتم تصدير الاعمدة المعروضة فقط علي الداتا قريد 


شكرا مقدما
(20-03-21, 07:24 PM)عبدالكريم برشدان كتب : [ -> ]السلام عليكم اصدقائي 

كيف حالكم جميعا 

كيف يمكنني تصدير اعمده التي انا احددها عن طريق CheckBox بحيث يتم تصدير الاعمدة المعروضة فقط علي الداتا قريد 


شكرا مقدما

PHP كود :
Private Sub Button1_Click(sender As ObjectAs EventArgsHandles Button1.Click
        
Try

            
Dim MsExcel CreateObject("Excel.Application")


            
MsExcel.Workbooks.Add()
            
MsExcel.Visible False



            Dim k 
As New ArrayList
            
If CheckBox1.Checked Then k.Add(0)
            If 
CheckBox2.Checked Then k.Add(1)
            If 
CheckBox3.Checked Then k.Add(2)

            
Dim g As Integer
            g 
0
            
For As Integer 0 To DataGridView1.Columns.Count 1

                
If Not k.Contains(iThen Continue For

                
1

                
'MsExcel.Cells(i + 1).Value = DataGridView1.Columns(i).HeaderText
                MsExcel.Cells(g).Value = DataGridView1.Columns(i).HeaderText


            Next


            g = 0
            For i As Integer = 0 To DataGridView1.Columns.Count - 1

                If Not k.Contains(i) Then Continue For

                g = g + 1

                For j As Integer = 0 To DataGridView1.Rows.Count - 1
                    MsExcel.Columns.HorizontalAlignment = 3


                    MsExcel.Columns.Font.Name = "Times New Roman"


                    '
MsExcel.Rows.Item(1).Font.Bold 1


                    
'MsExcel.Rows.Item(j + 1).Font.size = 14

                    MsExcel.Cells(j + 1).ColumnWidth = 14


                    '
MsExcel.Cells(21).Value DataGridView1.Rows(j).Cells(i).Value
                    MsExcel
.Cells(2g).Value DataGridView1.Rows(j).Cells(i).Value


                Next


            Next

            
If MsgBox("هل تريد فتح الملف"MsgBoxStyle.YesNo"تصدير البيانات") = MsgBoxResult.Yes Then
                
'frm_excel.TopMost = False
                MsExcel.Visible = True

            End If



        Catch ex As Exception


            MsgBox(ex.Message)


        End Try

    End Sub 
(20-03-21, 08:42 PM)Ronald كتب : [ -> ]
(20-03-21, 07:24 PM)عبدالكريم برشدان كتب : [ -> ]السلام عليكم اصدقائي 

كيف حالكم جميعا 

كيف يمكنني تصدير اعمده التي انا احددها عن طريق CheckBox بحيث يتم تصدير الاعمدة المعروضة فقط علي الداتا قريد 


شكرا مقدما

PHP كود :
   Private Sub Button1_Click(sender As ObjectAs EventArgsHandles Button1.Click
        Try

            Dim MsExcel 
CreateObject("Excel.Application")


 
           MsExcel.Workbooks.Add()
 
           MsExcel.Visible False



            Dim k 
As New ArrayList
            If CheckBox1
.Checked Then k.Add(0)
 
           If CheckBox2.Checked Then k.Add(1)
 
           If CheckBox3.Checked Then k.Add(2)

 
           Dim g As Integer
            g 
0
            For i 
As Integer 0 To DataGridView1.Columns.Count 1

                If Not k
.Contains(iThen Continue For

 
               g 1

                
'MsExcel.Cells(i + 1).Value = DataGridView1.Columns(i).HeaderText
                MsExcel.Cells(g).Value = DataGridView1.Columns(i).HeaderText


            Next


            g = 0
            For i As Integer = 0 To DataGridView1.Columns.Count - 1

                If Not k.Contains(i) Then Continue For

                g = g + 1

                For j As Integer = 0 To DataGridView1.Rows.Count - 1
                    MsExcel.Columns.HorizontalAlignment = 3


                    MsExcel.Columns.Font.Name = "Times New Roman"


                    '
MsExcel.Rows.Item(1).Font.Bold 1


                    
'MsExcel.Rows.Item(j + 1).Font.size = 14

                    MsExcel.Cells(j + 1).ColumnWidth = 14


                    '
MsExcel.Cells(21).Value DataGridView1.Rows(j).Cells(i).Value
                    MsExcel
.Cells(2g).Value DataGridView1.Rows(j).Cells(i).Value


                Next


            Next

            If MsgBox
("هل تريد فتح الملف"MsgBoxStyle.YesNo"تصدير البيانات") = MsgBoxResult.Yes Then
                
'frm_excel.TopMost = False
                MsExcel.Visible = True

            End If



        Catch ex As Exception


            MsgBox(ex.Message)


        End Try

    End Sub 
مشكور جدا باش مهندس
(20-03-21, 08:42 PM)Ronald كتب : [ -> ]
(20-03-21, 07:24 PM)عبدالكريم برشدان كتب : [ -> ]السلام عليكم اصدقائي 

كيف حالكم جميعا 

كيف يمكنني تصدير اعمده التي انا احددها عن طريق CheckBox بحيث يتم تصدير الاعمدة المعروضة فقط علي الداتا قريد 


شكرا مقدما

PHP كود :
   Private Sub Button1_Click(sender As ObjectAs EventArgsHandles Button1.Click
        Try

            Dim MsExcel 
CreateObject("Excel.Application")


 
           MsExcel.Workbooks.Add()
 
           MsExcel.Visible False



            Dim k 
As New ArrayList
            If CheckBox1
.Checked Then k.Add(0)
 
           If CheckBox2.Checked Then k.Add(1)
 
           If CheckBox3.Checked Then k.Add(2)

 
           Dim g As Integer
            g 
0
            For i 
As Integer 0 To DataGridView1.Columns.Count 1

                If Not k
.Contains(iThen Continue For

 
               g 1

                
'MsExcel.Cells(i + 1).Value = DataGridView1.Columns(i).HeaderText
                MsExcel.Cells(g).Value = DataGridView1.Columns(i).HeaderText


            Next


            g = 0
            For i As Integer = 0 To DataGridView1.Columns.Count - 1

                If Not k.Contains(i) Then Continue For

                g = g + 1

                For j As Integer = 0 To DataGridView1.Rows.Count - 1
                    MsExcel.Columns.HorizontalAlignment = 3


                    MsExcel.Columns.Font.Name = "Times New Roman"


                    '
MsExcel.Rows.Item(1).Font.Bold 1


                    
'MsExcel.Rows.Item(j + 1).Font.size = 14

                    MsExcel.Cells(j + 1).ColumnWidth = 14


                    '
MsExcel.Cells(21).Value DataGridView1.Rows(j).Cells(i).Value
                    MsExcel
.Cells(2g).Value DataGridView1.Rows(j).Cells(i).Value


                Next


            Next

            If MsgBox
("هل تريد فتح الملف"MsgBoxStyle.YesNo"تصدير البيانات") = MsgBoxResult.Yes Then
                
'frm_excel.TopMost = False
                MsExcel.Visible = True

            End If



        Catch ex As Exception


            MsgBox(ex.Message)


        End Try

    End Sub 


انا ايضاً استفدت من الرد

الف شكر لك

و الشكر موصول لصاحب الموضوع