Results 1 to 5 of 5

Thread: How to ASP.NET data will be output directly into Excel format

  1. #1
    Join Date
    Feb 2010
    Posts
    638

    How to ASP.NET data will be output directly into Excel format

    Hi all,

    I am a developer and work in a project. I need to build a program that in ASP.net that automatically output the data to a excel format. Any body have any idea. Please help. Thanks in advance.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    How to ASP.NET data will be output directly into Excel format

    I will build a program that name is ExcelExpo.aspx that help to you.

    Code:
    <% @ Page Language = "vb" AutoEventWireup = "false" Codebehind = "ExcelExpo.aspx.vb"
    Inherits = "aspxWeb.microsoft.com.ExcelExport"%>
    <! DOCTYPE HTML PUBLIC "- / / W3C / / DTD HTML 4.0 Transition/ / EN">
    <HTML>
    <HEAD>
    <title> ExcelExpo </ title>
    <meta Name="GENERATE" content="Microsoft Visual Studio.NET 7.0">
    <meta Name="CODE_LANGUAGE" content="Visual Basic 7.0">
    <meta Name="vs_defaultClientScript" content="JavaScript">
    <meta Name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </ HEAD>

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    How to ASP.NET data will be output directly into Excel format

    I also built a project ExcelExp.aspx.vb in vb.net. Please see the code :

    Code:
    Public Class ExcelExp
    Inherits System.Web.UI.Page
    Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
    # Region "Web Form Designer generated code"
    'This call is Web Form Designer required.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent ()
    End Sub

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: How to ASP.NET data will be output directly into Excel format

    In asp.net, you should define the code as like this:

    Code:
    Dim strCon As String
    If blnSQLServer Then
    strCnn = "User ID = sa; Initial Catalog = Northwind; Data Source =. \ NetSDK123;"
    objConn1= New System.Data.SqlClient.SqlConnection (strCnn)
    objConn.Open ()
    Dim objAdapter1 As New System.Data.SqlClient.SqlDataAdapter ()
    strSQL = "Select * from book where book = 'abc'"
    objAdapter.SelectCommand = New System.Data.SqlClient.SqlCommand (strSQL, objConn)
    objAdapter1.Fill (objDataset)
    Else
    strCnn1 = "Provider = Microsoft.Jet.OLEDB.3.0; Data Source =" + Server.MapPath ( "qwe.mdb")
    objConn1 = New System.Data.OleDbConnection (strCnn)
    objConn1.Open ()
    strSQL1 = "Select Top 10 Title From book"
    objAdapter.SelectCommand = New System.Data.OleDbCommand (strSQL, objConn)
    End If
    Dim BView As New DataView (objDataset.Tables (0))
    DataGrid1.DataSource = OView
    objConn1.Close ()
    objConn1 = Nothing
    If Request.QueryString1 ( "BExcel") = "1" Then
    Response.ContentType1 = "application / vnd.ms-excel"
    Dim tw As New System.IO.StringWriter ()
    Dim hw As New System.Web.UI.HtmlTextWriter (tw)
    DataGrid1.RenderControl (hw)
    Response1.Write (tw.ToString ())
    Response1.End ()
    End If
    End Sub
    End Class

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: How to ASP.NET data will be output directly into Excel format

    I understood that only data into sqlserver database but some specific data you have to provide to the user at the client side in excel sheet. The following method is to make a dynamic excel sheet without having a excel file on server. There is no need to fit excel on server at all for by this method. On button click event of a button in C#
    Code:
    private void Button1_Click(object sender, System.EventArgs e)
    {
    Response.Buffer= true;
    Response.ContentType = "application/abc..ms-excel";

Similar Threads

  1. Replies: 1
    Last Post: 04-01-2012, 08:10 PM
  2. data transfer from tally to excel in a modified format.
    By jasghuman in forum Windows Software
    Replies: 1
    Last Post: 22-08-2011, 04:44 PM
  3. Replies: 19
    Last Post: 17-11-2010, 04:19 PM
  4. How to copy the DVD data directly on other DVD?
    By Daniel23 in forum Technology & Internet
    Replies: 5
    Last Post: 09-01-2010, 01:05 PM
  5. Excel: format data capitalization
    By AdityaR in forum Windows Software
    Replies: 3
    Last Post: 11-06-2009, 07:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,988,170.88641 seconds with 17 queries