تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] نسخ من DataGridView ولصق في Excel
#4
هذا كود للاخ حسام الشامي ... من خارج الموقع


PHP كود :
Imports Excel Microsoft.Office.Interop.Excel 
PHP كود :
Dim rowsTotalcolsTotal As Short
        Dim I
jiC As Short
        System
.Windows.Forms.Cursor.Current System.Windows.Forms.Cursors.WaitCursor
        Dim xlApp 
As New Excel.Application
        
Try
            
Dim excelBook As Microsoft.Office.Interop.Excel.Workbook xlApp.Workbooks.Add
            Dim excelWorksheet 
As Microsoft.Office.Interop.Excel.Worksheet CType(excelBook.Worksheets(1), Excel.Worksheet)
            
xlApp.Visible True
            rowsTotal 
DataGridView1.RowCount 1
            colsTotal 
DataGridView1.Columns.Count 1
            Dim currCol 
As Integer 1
            With excelWorksheet
                
.Cells.Select()
                .
Cells.Delete()
                For 
iC 0 To colsTotal

                    
If DataGridView1.Columns(iC).Visible True Then
                        
.Cells(1currCol).Value DataGridView1.Columns(iC).HeaderText
                        currCol 
currCol 1
                    End 
If

                
Next


                
For 0 To rowsTotal
                    currCol 
1
                    
For 0 To colsTotal
                        
If DataGridView1.Columns(j).Visible True Then
                            
.Cells(2currCol).value DataGridView1.Rows(I).Cells(j).FormattedValue
                            currCol 
currCol 1
                        End 
If
                    
Next j
                Next I

                
.Rows("1:1").Font.FontStyle "Bold"
                
.Rows("1:1").Font.Size 10
                
.Cells.Columns.AutoFit()
                .
Cells.Select()
                .
Cells.EntireColumn.AutoFit()
                .
Cells(11).Select()
            
End With
        
Catch ex As Exception
            MsgBox
("Export Excel Error " ex.Message)
        Finally
            
System.Windows.Forms.Cursor.Current System.Windows.Forms.Cursors.Default
            
xlApp Nothing
        End 
Try 
الرد }}}
تم الشكر بواسطة: Sajad , asemshahen5


الردود في هذا الموضوع
نسخ من DataGridView ولصق في Excel - بواسطة OsamaVB - 24-12-13, 04:16 PM
RE: نسخ من DataGridView ولصق في Excel - بواسطة tarek - 24-12-13, 04:50 PM
RE: نسخ من DataGridView ولصق في Excel - بواسطة OsamaVB - 24-12-13, 04:57 PM
RE: نسخ من DataGridView ولصق في Excel - بواسطة مالكـ - 26-12-13, 04:29 AM
RE: نسخ من DataGridView ولصق في Excel - بواسطة OsamaVB - 26-12-13, 11:39 PM
RE: نسخ من DataGridView ولصق في Excel - بواسطة Sajad - 27-12-13, 12:06 AM


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


يقوم بقرائة الموضوع: