السلام عليكم
لدي تقرير بالبرنامج يحتوي على أكثر من مائة ألف سجل ، وأقوم بتصديرها مباشرة على sheet اكسل ، ولكن المشكلة ان عدد سجلات الــ sheet الواحد حوالي 65 ألف ، ولهذا لا يظهر التقرير ، ما أريد فعله هو أن يحتوي الـ Sheet الأول على 50000 سجل وبعد ذلك ينتقل الى الــSheet ألثاني ويضع فيه الـ 50000 الاخرى ، وهكذا .......
وهذا هو الكود :
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US")
Dim xlWb As excel.Workbook
Dim xlWs As excel.Worksheet
Dim chartrg As excel.Range
Dim data(1)() 'two dimension array
Dim fldCount As Integer
Dim recCount As Long
Dim iCol As Integer
Dim iRow As Integer
' Create an instance of Excel and add a workbook
xlApp = CreateObject("Excel.Application")
xlWb = xlApp.Workbooks.Add
xlWs = xlWb.Worksheets("Sheet1")
fldCount = DGV1.ColumnCount
ReDim data(0)(fldCount)
For iCol = 1 To fldCount
xlWs.Cells(1, iCol).Value = DGV1.Columns(iCol - 1).HeaderText
Next
recCount = DGV1.Rows.Count + 1
For iRow = 2 To recCount
For iCol = 1 To fldCount
data(0)(iCol - 1) = Me.DGV1.Rows(iRow - 2).Cells(iCol - 1).Value
Next
xlWs.Range(xlWs.Cells(iRow, 1), xlWs.Cells(iRow, iCol - 1)).Value = data(0)
Next
chartrg = xlWs.Range("A1", xlWs.Cells(iRow - 1, iCol - 1))
chartrg.Borders(excel.XlBordersIndex.xlInsideHorizontal).LineStyle = excel.XlLineStyle.xlContinuous
chartrg.Borders(excel.XlBordersIndex.xlInsideVertical).LineStyle = excel.XlLineStyle.xlContinuous
chartrg.Borders(excel.XlBordersIndex.xlEdgeBottom).LineStyle = excel.XlLineStyle.xlContinuous
chartrg.Borders(excel.XlBordersIndex.xlEdgeTop).LineStyle = excel.XlLineStyle.xlContinuous
chartrg.Borders(excel.XlBordersIndex.xlEdgeRight).LineStyle = excel.XlLineStyle.xlContinuous
chartrg.HorizontalAlignment = 3
chartrg.VerticalAlignment = 3
chartrg.Range("A1", xlWs.Cells(1, iCol - 1)).Interior.Color = RGB(252, 243, 66)
xlApp.Selection.CurrentRegion.Columns.AutoFit()
xlApp.Selection.CurrentRegion.Rows.AutoFit()
' Display Excel and give user control of Excel's lifetime
xlApp.Visible = True
xlApp.UserControl = True
' Release Excel references
xlWs = Nothing
xlWb = Nothing
xlApp = Nothing
Cursor = Cursors.Default
GC.Collect()
GC.WaitForPendingFinalizers()اشكركم مقدما