16-12-20, 02:29 PM
وعليكم السلام ورحمة الله
اذا كنت بتصدر البيانات من جريدفيو فهذا كود جيد وفعال ،،، جرب ورد خبر
اذا كنت بتصدر البيانات من جريدفيو فهذا كود جيد وفعال ،،، جرب ورد خبر
PHP كود :
Dim rowsTotal, colsTotal As Short
Dim I, j, iC As Short
Cursor.Current = Cursors.WaitCursor
Dim xlApp As New Excel.Application
Try
Dim excelBook As Excel.Workbook = xlApp.Workbooks.Add
Dim excelWorksheet As Excel.Worksheet = CType(excelBook.Worksheets(1), Excel.Worksheet)
xlApp.Visible = True
rowsTotal = DataGridView1.RowCount
colsTotal = DataGridView1.Columns.Count - 1
With excelWorksheet
For iC = 0 To colsTotal
.Cells(1, iC + 1).Value = DataGridView1.Columns(iC).HeaderText
Next
For I = 0 To rowsTotal - 1
For j = 0 To colsTotal
.Cells(I + 2, j + 1).value = DataGridView1.Rows(I).Cells(j).Value
Next j
Next I
.Cells.Columns.AutoFit()
.Cells.EntireColumn.AutoFit()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
Cursor.Current = Cursors.Default
xlApp = Nothing
End Try
