منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
تصدير DataGridView الى xls - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم مقالات VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=184)
+--- الموضوع : تصدير DataGridView الى xls (/showthread.php?tid=15232)

الصفحات: 1 2 3


RE: تصدير DataGridView الى xls - asemshahen5 - 24-06-22

هذه الامور يمكن التحكم بها بالداتاغريد فيو قبل عملية التصدير .


RE: تصدير DataGridView الى xls - atefkhalf2004 - 25-06-22

رغم التحكم ما زال يعض تاريخ طويل به الزمن
ومش عارف احل المشكلة


RE: تصدير DataGridView الى xls - asemshahen5 - 08-07-22

جرب هذا الكود ليتحكم بتنسيق التاريخ في الداتا غريد فيو :

PHP كود :
    '++++++++++++++++++++++++++++'
    'تنسيق التاريخ DataGridView1'
 
   Private Sub DataGridView1_CellFormatting(sender As ObjectAs DataGridViewCellFormattingEventArgsHandles DataGridView1.CellFormatting
        If e
.ColumnIndex 0 Then
            If e
.RowIndex DataGridView1.Rows.Count 1 Then Exit Sub
            e
.Value CDate(e.Value)
 
           e.CellStyle.Format "yyyy-MM-dd"
 
       End If
 
   End Sub
   
'++++++++++++++++++++++++++++' 



RE: تصدير DataGridView الى xls - atefkhalf2004 - 08-07-22

شكرا جاري التجربة


RE: تصدير DataGridView الى xls - atefkhalf2004 - 08-07-22

كود :
Private Sub DataGridView2_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DataGridView2.CellFormatting
       If e.ColumnIndex = 3 Then
           If e.RowIndex = DataGridView2.Rows.Count - 1 Then Exit Sub
           e.Value = CDate(e.Value)
           e.CellStyle.Format = "yyyy-MM-dd"
       End If
   End Sub

اضفت هذا  ولم يحدث  تغيير
لا بد م الاضافة   في الموديول
اعتقد هذا

For intRow As Integer = 0 To DgvCountRow 'DGV.RowCount - 1
Application.DoEvents()
.WriteLine(" <Row ss:StyleID=""ksg"" ss:utoFitHeight =""0"">")
For intCol As Integer = 2 To DGV.Columns.Count - 1
Application.DoEvents()
.WriteLine(" <Cell ss:StyleID=""isi"">")
.WriteLine(" <Data ss:Type=""String"">{0}</Data>", DGV.Item(intCol, intRow).Value.ToString)
.WriteLine(" </Cell>")
'DGV.Columns(4).Visible = False
Next
.WriteLine(" </Row>")
Next


RE: تصدير DataGridView الى xls - asemshahen5 - 08-07-22

هذا الكود يضاف في الفورم التي تحتوي على DataGridView .
1- غير هذا السطر من DataGridView2_CellFormatting الى اسم جدولك_CellFormatting و Handles DataGridView2.CellFormatting الى Handles اسم جدولك.CellFormatting
2- غير الرقم الموجود في If e.ColumnIndex = 3 Then الى رقم عامود التاريخ في الجدول و يجب بدأ العد من الصفر .


RE: تصدير DataGridView الى xls - atefkhalf2004 - 09-07-22

PHP كود :
  Private Sub CellFormatting_following(ByVal sender As ObjectByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgsHandles CellFormatting.following
        If e
.ColumnIndex 3 Then
            If e
.RowIndex DataGridView2.Rows.Count 1 Then Exit Sub
            e
.Value CDate(e.Value)
 
           e.CellStyle.Format "yyyy-MM-dd"
 
       End If
 
   End Sub 

يعطي خطا تحت  
PHP كود :
Handles CellFormatting.following 



RE: تصدير DataGridView الى xls - asemshahen5 - 09-07-22

Handles DataGridView2.CellFormatting
DataGridView2_CellFormatting


RE: تصدير DataGridView الى xls - atefkhalf2004 - 09-07-22

d_visit
5/20/2022 12:00:00 AM
5/20/2022 12:00:00 AM
5/20/2022 12:00:00 AM
5/21/2022 12:00:00 AM
5/21/2022 12:00:00 AM
5/21/2022 12:00:00 AM
6/23/2022 12:00:00 AM
6/23/2022 12:00:00 AM


ما زال يعرض كما بالصورة
كل عام وانتم بخير
برجاء حل مشكلتي


RE: تصدير DataGridView الى xls - asemshahen5 - 09-07-22

ما اسم الجدول .