10-02-15, 11:40 PM
[align=right]بسم الله الرحمن الرحيم
الاخوة الاعزاء اسعد الله مساكم اين ماكنتم ووفقكم الي الخير
حقيقتا لدي اشكال في الكود الذي سوف ارفقه ادناه وما اعانية انه عندما اصدر البيانات الي ملف اكسل اجد البيانات تتكرر ولايتم جلب كافة البيانات المطلوبة
الاخوة الاعزاء اسعد الله مساكم اين ماكنتم ووفقكم الي الخير
حقيقتا لدي اشكال في الكود الذي سوف ارفقه ادناه وما اعانية انه عندما اصدر البيانات الي ملف اكسل اجد البيانات تتكرر ولايتم جلب كافة البيانات المطلوبة
إقتباس :Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM actions ORDER BY ordernumber", cn, adOpenStatic, adLockOptimistic
If rs.RecordCount <= 0 Then
MsgBox "áÇ ÊæÌÏ ÈíÇäÇÊ Ýí ÇáÞÇÚÏÉ ÇáÈíÇäÇÊ"
Else
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
Set xlApp = CreateObject("Excel.Application")
xlApp.SheetsInNewWorkbook = 1
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Add
xlApp.Windows(1).ActiveSheet.Name = "sheet"
Set xlSheet = xlBook.Worksheets("Sheet")
xlSheet.Range("B6").CopyFromRecordset rs
xlSheet.cells(3, 3).Value = Date
xlSheet.cells(3, 1).Value = "Report printed "
xlSheet.cells(5, 2).columnWidth = 5
xlSheet.cells(5, 1).columnWidth = 5
xlSheet.cells(5, 1).Value = "Ê"
xlSheet.cells(5, 1).columnWidth = 3
xlSheet.cells(5, 2).columnWidth = 10
xlSheet.cells(5, 2).Value = "ÇãÑ ÇáÚãá"
xlSheet.cells(5, 3).columnWidth = 10
xlSheet.cells(5, 3).Value = "ÑÞã ÇáãÎØØ"
xlSheet.cells(5, 4).columnWidth = 14
xlSheet.cells(5, 4).Value = "ãÌãæÚ ÇáãÎØØÇÊ"
xlSheet.cells(5, 5).columnWidth = 10
xlSheet.cells(5, 5).Value = "ÇáãÞÓã"
xlSheet.cells(5, 6).columnWidth = 10
xlSheet.cells(5, 6).Value = "ÇáßÈíäå"
xlSheet.cells(5, 7).columnWidth = 10
xlSheet.cells(5, 7).Value = "äæÚ ÇáÚãá"
xlSheet.cells(5, 8).columnWidth = 10
xlSheet.cells(5, 8).Value = "SITE FOC"
xlSheet.cells(5, 9).columnWidth = 10
xlSheet.cells(5, 9).Value = "RACK"
xlSheet.cells(5, 10).columnWidth = 10
xlSheet.cells(5, 10).Value = "POSTION"
xlSheet.cells(5, 11).columnWidth = 10
xlSheet.cells(5, 11).Value = "Fiber"
xlSheet.cells(5, 12).columnWidth = 10
xlSheet.cells(5, 12).Value = "Capillaries"
xlSheet.cells(5, 13).columnWidth = 10
xlSheet.cells(5, 13).Value = "NEW_DP"
xlSheet.cells(5, 14).columnWidth = 10
xlSheet.cells(5, 14).Value = "FIM"
xlSheet.cells(5, 15).columnWidth = 10
xlSheet.cells(5, 15).Value = "DP"
xlSheet.cells(5, 16).columnWidth = 10
xlSheet.cells(5, 16).Value = "BSW"
xlSheet.cells(5, 17).columnWidth = 10
xlSheet.cells(5, 17).Value = "REMARKS"
xlSheet.cells(5, 18).columnWidth = 10
xlSheet.cells(5, 18).Value = "FOC_Type"
xlSheet.cells(5, 19).columnWidth = 10
xlSheet.cells(5, 19).Value = "DB_Type"
xlSheet.cells(5, 20).columnWidth = 10
xlSheet.cells(5, 20).Value = "ÈÏÇíÉ ÇáÚãá"
xlSheet.cells(5, 21).columnWidth = 10
xlSheet.cells(5, 21).Value = "ÇÞÝÇá ÇáÚãá"
xlSheet.cells(5, 22).columnWidth = 10
xlSheet.cells(5, 22).Value = "ÇáãÞÇæá"
xlSheet.cells(5, 23).columnWidth = 10
xlSheet.cells(5, 23).Value = "ÇáãÝÊÔ"
xlSheet.cells(5, 24).columnWidth = 14
xlSheet.cells(5, 24).Value = "ÊÇÑíÎ ÊÓÌíá ÇáÚãá"
xlSheet.cells(5, 25).columnWidth = 10
xlSheet.cells(5, 25).Value = "ÍÇáÉ ÇáÚãá"
xlSheet.cells(5, 26).columnWidth = 80
xlSheet.cells(5, 26).Value = "ãáÇÍÙÇÊ"
xlSheet.Range("a5:z5").Font.Bold = True
xlSheet.cells(6, 1).Value = 1
xlSheet.cells(7, 1).Value = 2
xlSheet.Range("a6:B7").AutoFill Destination:=xlSheet.Range("a6:B" & rs.RecordCount + 5), Type:=xlLinearTrend
xlSheet.Range("a5:z" & rs.RecordCount + 5).Borders.Weight = xlThin
xlSheet.Range("a5:z" & rs.RecordCount + 7).Font.Size = 10
xlSheet.Range("a5:z" & rs.RecordCount + 7).Font.Color = &H404080
xlSheet.Range("a5:z" & rs.RecordCount + 7).Font.Name = "Times New Roman"
xlSheet.Range("a5:z" & rs.RecordCount + 7).HorizontalAlignment = xlCenter
xlSheet.Range("a5:z" & rs.RecordCount + 7).VerticalAlignment = xlVAlignCenter
xlSheet.Range("F" & rs.RecordCount + 7).NumberFormat = "###,##0.00"
xlSheet.Range("E" & rs.RecordCount + 7 & ":F" & rs.RecordCount + 7).Font.Bold = True
xlSheet.Range("E" & rs.RecordCount + 7 & ":F" & rs.RecordCount + 7).Borders.Weight = xlThin
End If
ErrHandler: