Click here to Skip to main content
11,483,586 members (71,276 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
i am using vb.net framework 2.0 and want to create excel file. please send me code to create a simple excel file..

thanks
Balmukund
Posted 29-Feb-12 21:59pm
Comments
Varun Sareen at 1-Mar-12 3:27am
   
always try google search dear.
Balmukund Dewangan at 1-Mar-12 5:25am
   
Hi.. thanks to reply. but my problem is still not solved. you have sent me 3 links
1. is about creating excel file in C#
2. is for desktop based application in vb.net
3. is link to search in google

I have tried in google so many times but coundnt get correct one..

What i need is "creating excel file in vb.net framework 2.0 in web based tech"

Thanks
Balmukund
Varun Sareen at 1-Mar-12 23:44pm
   
i have updated my solution.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Before Improve this code add reference
"Microsoft Excel 12.0 Object Library"

Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object,_
	 ByVal e As System.EventArgs) Handles Button1.Click
 
        Dim xlApp As Excel.Application
        Dim xlWorkBook As Excel.Workbook
        Dim xlWorkSheet As Excel.Worksheet
        Dim misValue As Object = System.Reflection.Missing.Value
 
        xlApp = New Excel.ApplicationClass
        xlWorkBook = xlApp.Workbooks.Add(misValue)
        xlWorkSheet = xlWorkBook.Sheets("sheet1")
        xlWorkSheet.Cells(1, 1) = "http://neerajsinghandroid.blogspot.in"
        xlWorkSheet.SaveAs("C:\vbexcel.xlsx")
 
        xlWorkBook.Close()
        xlApp.Quit()
 
        releaseObject(xlApp)
        releaseObject(xlWorkBook)
        releaseObject(xlWorkSheet)
 
        MsgBox("Excel file created , you can find the file c:\")
    End Sub
 
    Private Sub releaseObject(ByVal obj As Object)
        Try
            System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
            obj = Nothing
        Catch ex As Exception
            obj = Nothing
        Finally
            GC.Collect()
        End Try
    End Sub
 
End Class
  Permalink  
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100