Solved

how can i create excel file  using vb.net , but i did not install excel application in my system.

Posted on 2009-04-15
9
324 Views
Last Modified: 2012-05-06
how can i create excel file  using vb.net , but i did not install excel application in my system.
0
Comment
Question by:mseit
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 24147557
Generate Excel files without using Microsoft Excel
http://www.codeproject.com/KB/office/biffcsharp.aspx
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
ID: 24147573
Reading and Writing Excel Spreadsheets Using ADO.NET C# DbProviderFactory
http://davidhayden.com/blog/dave/archive/2006/05/26/2973.aspx

Writing data to excel using oledb
http://p2p.wrox.com/c/1745-create-excel-file-without-excel-being-installed.html
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24147620
I'm not sure if it comes standard with Visual Studio, but on your References dialog, underneath the COM tab there should be a listing for Microsoft Excel [version #] Object Library, or similar. You can add a reference to that and create Excel applications/files.
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 24147629
@Kaufmed --> this comes only if you have owc or excel installed on the pc !
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Expert Comment

by:rdskill
ID: 24148010
This worked for me.

David
        Dim connectionStringTemplate As String = "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=" & _

                                c_FileName & ";DefaultDir=" & My.Settings.SaveAttachmentTo & ";"
 

        Dim cn As String = connectionStringTemplate

        Dim sqlSelect As String = "SELECT * FROM [DigitraceExportqy$];"    ' The name of the worksheet followed by $.       

        ' Load the Excel worksheet into a DataTable      

        Dim workbook As DataSet = New DataSet()

        Dim excelAdapter As System.Data.Common.DataAdapter = _

                New System.Data.Odbc.OdbcDataAdapter(sqlSelect, cn)

        Try

            excelAdapter.Fill(workbook)

            Dim ws As DataTable = workbook.Tables(0)

            ' build table for converted data

            Dim tbl As New DataTable

            tbl.Columns.Add("Type")

            tbl.Columns.Add("Order")

            tbl.Columns.Add("Active?")

            tbl.Rows.Add(row)
 

        Catch ex As Exception

            MessageBox.Show(ex.Message, My.Settings.ProgramTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
 

        End Try

Open in new window

0
 

Expert Comment

by:rdskill
ID: 24148059
sorry.... goofed the snippet copy...  
        Dim connectionStringTemplate As String = "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=" & _

                                FileName & ";DefaultDir=" & My.Settings.SaveAttachmentTo & ";"
 

        Dim cn As String = connectionStringTemplate

        Dim sqlSelect As String = "SELECT * FROM [DigitraceExportqy$];"    ' The name of the worksheet followed by $.       

        ' Load the Excel worksheet into a DataTable      

        Dim workbook As DataSet = New DataSet()

        Dim excelAdapter As System.Data.Common.DataAdapter = _

                New System.Data.Odbc.OdbcDataAdapter(sqlSelect, cn)

        Try

            excelAdapter.Fill(workbook)

            Dim ws As DataTable = workbook.Tables(0)

            ' build table for converted data

            Dim tbl As New DataTable

            tbl.Columns.Add("Type")

            tbl.Columns.Add("Order")

            tbl.Columns.Add("Active?")

  

            For Each wsRow As DataRow In ws.Rows

                Dim row As DataRow = tbl.NewRow

                row(0) = wsRow.Item(1).ToString.ToUpper         

                row(1) = wsRow.Item(13).ToString.ToUpper        

                row(2) = wsRow.Item(2).ToString.ToUpper         

	        tbl.Rows.Add(row)

	    next
 

        Catch ex As Exception

            MessageBox.Show(ex.Message, My.Settings.ProgramTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
 

        End Try

Open in new window

0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 24148172
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24148509
@Dhaest -- Yeah I wasn't sure about that, but I could have sworn I saw a download for an Office SDK that was independent of the suite. But I can't find it now. No visit from the SDK fairy this time  :(
0
 

Author Closing Comment

by:mseit
ID: 31570417
Good
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Tabcontrol Caption? 1 31
VB.Net - ReportViewer Windows Form many reports 2 24
Help with sorting data in Listbox using VB.NET 3 53
LINQ - C# to VB convertion 12 48
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now