  | 
                       | 
          
            
               
                 Convert เป็น VB.NET ให้ครับ 
 
Code (VB.NET) 
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.IO
Imports Excel = Microsoft.Office.Interop.Excel
Namespace ExcelC
	Public Partial Class frmExcel
		Inherits Form
		Public Sub New()
			InitializeComponent()
		End Sub
		Private Sub btnExcel_Click(sender As Object, e As EventArgs)
			Dim xlApp As Excel.Application
			Dim xlWorkBook As Excel.Workbook
			Dim xlWorkSheet As Excel.Worksheet
			Dim mis As Object = Type.Missing
			Dim strFileName As String = "C:\ExcelC\Xls\GenExcel.xls"
			xlApp = New Excel.ApplicationClass()
			xlWorkBook = xlApp.Workbooks.Add(mis)
			'xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.Add(mis, mis, mis, mis); /*** for Add New Sheet ***/
			xlWorkSheet = DirectCast(xlWorkBook.Worksheets.get_Item(1), Excel.Worksheet)
			xlWorkSheet.Name = "My Sheet"
			xlWorkSheet.Cells(1, 1) = "www.ThaiCreate.Com"
			xlWorkSheet.Cells(2, 1) = "Mr.Weerachai Nukitram"
			xlWorkBook.SaveAs(strFileName, mis, mis, mis, mis, mis, _
				Excel.XlSaveAsAccessMode.xlExclusive, mis, mis, mis, mis, mis)
			xlWorkBook.Close(True, mis, mis)
			xlApp.Quit()
			System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
			System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWorkBook)
			System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWorkSheet)
			xlApp = Nothing
			xlWorkBook = Nothing
			xlWorkSheet = Nothing
			GC.Collect()
			MessageBox.Show("Generate Successfully")
		End Sub
	End Class
End Namespace
                        
               
               | 
             
            
              
			  			  
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-12-23 17:07:17 | 
                        By :
                            webmaster | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             |