Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6648311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:38:26+00:00 2026-05-26T00:38:26+00:00

I am unable to export my data into excel. I have tried the suggestions

  • 0

I am unable to export my data into excel.
I have tried the suggestions on S/O, but have not had any luck.

        Dim sqlString As String = "spExportRateProfile" & Session("OfficeNumber") & "," & Session("SalesRepID")
        Dim conn As SqlConnection = New SqlConnection(Utils.GetConfigKey("ConnectionStringVimas"))
        conn.Open()
        Dim dt As DataTable = New DataTable()
        Dim da As SqlDataAdapter = New SqlDataAdapter(sqlString, conn)
        da.Fill(dt)

        Response.AddHeader("content-disposition", "attachment;filename=ReportExport.xlsx")
        Response.ContentType = "application/vnd.ms-excel"  

What do I need do after this to export my data to excel?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:38:27+00:00Added an answer on May 26, 2026 at 12:38 am

    You could use a ExcelLibrary like EPPlus(GPL) which i can warmly recommend.

    Then it is as easy as this to create Excel-Files from a DataTable and write it to the Response:

    Dim pck = New ExcelPackage()
    Dim ws = pck.Workbook.Worksheets.Add("Worksheet-Name")
    ws.Cells("A1").LoadFromDataTable(dt, True, OfficeOpenXml.Table.TableStyles.Medium1)
    Response.Clear()
    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
    Response.AddHeader("content-disposition", "attachment;  filename=ExcelFileName.xlsx")
    Response.BinaryWrite(pck.GetAsByteArray())
    

    Here is another example: http://epplus.codeplex.com/wikipage?title=WebapplicationExample

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have manage to export data from our mysql table into a .txt file.
I have some data to export from DB and save as CSV file, and
I have been searching for quite a while now but i am unable to
I'm trying to understand why I am unable to import a data sheet into
I have searched S/O, but unable to find a solution that helps my problem.
I am trying to export some data to Excel. I am using OLEDB 12.
I wrote a small program in VB.NET to export data from DataGrid to Excel
Error: Unable to read data from the transport connection: A blocking operation was interrupted
I have been unable to get Visual Studio to present intellisense when working with
I am unable to understand the usefulness of LOOPNE. Even if LOOPNE was not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.