المشاركات : 223
المواضيع 65
الإنتساب : Oct 2016
السمعة :
12
الشكر: 170
تم شكره 107 مرات في 77 مشاركات
18-01-17, 12:31 PM
(آخر تعديل لهذه المشاركة : 19-01-17, 12:22 PM {2} بواسطة thevirus.)
السلام عليكم ورحمة الله وبركاته
اخواني انا عندي برنامج يقوم بتصدير ملفات اكسل عندما احفظها يقول لي ان الملف للقراءة فقط كيف احفظ الملف للقراءة والكتابة
لا شيء مستحيل
المشاركات : 7
المواضيع 0
الإنتساب : Sep 2016
السمعة :
0
الشكر: 0
تم شكره 1 مرات في 1 مشاركات
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
ده كود شغال معايا تمام وبيخرج الاكسل ومفيش اي مشكلة جربو