![]() |
|
حول التصدير إلى أكسل - نسخة قابلة للطباعة +- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb) +-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182) +--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183) +--- الموضوع : حول التصدير إلى أكسل (/showthread.php?tid=18855) |
حول التصدير إلى أكسل - thevirus - 18-01-17 السلام عليكم ورحمة الله وبركاته اخواني انا عندي برنامج يقوم بتصدير ملفات اكسل عندما احفظها يقول لي ان الملف للقراءة فقط كيف احفظ الملف للقراءة والكتابة RE: حول التصدير إلى أكسل - thevirus - 19-01-17 ............ RE: حول التصدير إلى أكسل - ahmed.nabil - 19-01-17 Dim exlapp As New Application Dim exlworkbook As Workbook Dim exlworksheet As Worksheet Dim misvalue As Object = System.Reflection.Missing.Value exlworkbook = exlapp.Workbooks.Add(misvalue) exlworksheet = exlworkbook.Sheets("Sheet1") For colhead As Integer = 1 To DataGridView1.ColumnCount - 1 exlworksheet.Cells(1, colhead + 1) = DataGridView1.Columns(colhead).HeaderText Next For i As Integer = 0 To DataGridView1.RowCount - 1 For j As Integer = 1 To DataGridView1.ColumnCount - 1 exlworksheet.Cells(i + 2, j + 1) = DataGridView1.Rows(i).Cells(j).Value.ToString Next Next sfd1.FileName = "" sfd1.Filter = "Excel 2003| *.xls | Excel 2007| *.xlsx " If sfd1.ShowDialog = System.Windows.Forms.DialogResult.OK Then exlworksheet.SaveAs(sfd1.FileName) Else Exit Sub End If exlworkbook.Close() exlapp.Quit() System.Runtime.InteropServices.Marshal.ReleaseComObject(exlapp) System.Runtime.InteropServices.Marshal.ReleaseComObject(exlworkbook) System.Runtime.InteropServices.Marshal.ReleaseComObject(exlworksheet) exlapp = Nothing exlworkbook = Nothing exlworksheet = Nothing If MsgBox("Do You Want To Open File ", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then Process.Start(sfd1.FileName) End If ده كود شغال معايا تمام وبيخرج الاكسل ومفيش اي مشكلة جربو RE: حول التصدير إلى أكسل - thevirus - 21-01-17 (19-01-17, 09:34 PM)ahmed.nabil كتب : Dim exlapp As New Application حبيبي |