seminar seminar
well, actually my final presentation has ended, but bt juga, Mr. Julio ga dateng, n kata temen gwe pa jul ada di kantornya, what's the ?
but aniwey, thx to all my frens who has came to my presentation....
hhmmm... ternyata export to excel dari datagrid ga telalu susah juga,...
sekian lama ngutak-ngatik, mungkin ini sourcenya
Dim ExcelFile_Path As String
Dim dtMhs As New DataTable
Function exportToExc()
Dim objExcel As New OWC.Spreadsheet 'Reference dari Microsoft Office Web Compenents 9.0
Dim myRow As DataRow
Dim myColumn As New DataColumn
Dim RowCount As Object
Dim ColumnCount As Object
saveExcell.Filter = "Microsoft Office Excel Files (*.xls)|*.xls"
If saveExcell.ShowDialog() <> DialogResult.OK Then Exit Function
ExcelFile_Path = saveExcell.FileName
If File.Exists(ExcelFile_Path) = True Then File.Delete(ExcelFile_Path)
Me.Cursor = Cursors.WaitCursor
'Add the column headers
For Each myColumn In dtMhs.Columns
ColumnCount += 1
objExcel.ActiveSheet.Cells(1, ColumnCount) = myColumn.ColumnName
Next
ColumnCount = 0
RowCount = 0
'Add the data
For Each myColumn In dtMhs.Columns
ColumnCount += 1
RowCount = 1
For Each myRow In dtMhs.Rows
RowCount += 1
'check whether the value has null
If IsDBNull(myRow(myColumn)) Then
objExcel.ActiveSheet.Cells(RowCount, ColumnCount) = "{KOSONG}"
Else
objExcel.ActiveSheet.Cells(RowCount, ColumnCount) = CStr(myRow(myColumn))
End If
Next
Next
ColumnCount = 0
'Autofit the columns
For Each myColumn In dtMhs.Columns
ColumnCount += 1
objExcel.ActiveSheet.Columns(ColumnCount).EntireColumn.AutoFitColumns()
Next
'Do any formatting you wish
'objExcel.ActiveSheet.Columns.InsertColumns(1)
objExcel.ActiveSheet.Rows.InsertRows(2)
objExcel.ActiveSheet.Cells(1, 1) = "Data Mahasiswa Program Studi " & _
lblInfoPS.Text & " angkatan " & cbAngkatan.Text
objExcel.ActiveSheet.Rows(1).Font.Bold = True
objExcel.ActiveSheet.Rows(3).Font.Bold = True
'save export
objExcel.ActiveSheet.Export(ExcelFile_Path, OWC.SheetExportActionEnum.ssExportActionNone)
MsgBox("Penyimpanan berhasil")
End Function
--gotchaaaaa :D
[ Buster Bladder ]
1 Comments:
Get any Desired College Degree, In less then 2 weeks.
Call this number now 24 hours a day 7 days a week (413) 208-3069
Get these Degrees NOW!!!
"BA", "BSc", "MA", "MSc", "MBA", "PHD",
Get everything within 2 weeks.
100% verifiable, this is a real deal
Act now you owe it to your future.
(413) 208-3069 call now 24 hours a day, 7 days a week.
Post a Comment
<< Home