[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

09/21/2007 at 07:34AM PDT, ID: 22844222
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.4

get open/save as dialog box instead of saving automatically as excel

Asked by ewesley in Programming for ASP.NET, .NET Framework 2.x, Visual Studio

Tags: dialog, excel, box, open, save

Hello,

I am using asp.net with vb.net for my back code, i am successfully saving a datatable from my database as excel. I however would like to get the 'open/save as' dialog box to give the users an option to open the file immediately. Please advice, my code is below

Public Shared Sub DataToExcel(ByVal p_tablename As String, ByVal p_DT As DataTable)
        Dim oXL As Object
        Dim oBook As Object
        Dim oSheet As Object
        Dim iRow As Integer
        Dim iCol As Integer


        oXL = CreateObject("Excel.Application")
        oBook = oXL.Workbooks.Add
        oSheet = oBook.Worksheets(1)

        ' Dim sValue As String

        If oXL Is Nothing Then
            ''throw an exception
            Throw (New Exception("Unable to Start Microsoft Excel"))
        End If
        With oSheet
            'enter header to XL
            For iCol = 0 To p_DT.Columns.Count - 1
                .Cells(1, iCol + 1) = p_DT.Columns(iCol).ToString
            Next
            'enter data to XL
            For iRow = 0 To p_DT.Rows.Count - 1
                For iCol = 0 To p_DT.Columns.Count - 1
                    'start with 2nd row , 1st column
                    .Cells(iRow + 2, iCol + 1) = p_DT.Rows(iRow).Item(iCol)
                Next iCol
                'sValue = sValue & vbCrLf
            Next iRow
            oSheet.Rows("1:1").Font.FontStyle = "Bold"
            oSheet.Columns("A:A").NumberFormat = "0"
            oSheet.Columns.Autofit()
        End With

        Try
            oXL.DisplayAlerts = False
            oSheet.SaveAs(p_tablename)
        Catch
        End Try

        oXL.Workbooks.Close()
        oXL.Quit()
        While (System.Runtime.InteropServices.Marshal.ReleaseComObject(oXL) <> 0)
        End While
        oXL = Nothing
        oBook = Nothing
        GC.Collect()
    End Sub
 
Keywords: get open/save as dialog box instead …
 
Loading Advertisement...
 
[+][-]09/21/07 08:05 AM, ID: 19936195

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/21/07 08:54 AM, ID: 19936647

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/21/07 09:05 AM, ID: 19936758

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/21/07 11:28 AM, ID: 19937896

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/21/07 11:34 AM, ID: 19937955

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/21/07 01:31 PM, ID: 19938953

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/21/07 01:33 PM, ID: 19938965

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/21/07 01:40 PM, ID: 19939018

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/21/07 02:04 PM, ID: 19939204

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/21/07 02:17 PM, ID: 19939298

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/26/07 07:49 AM, ID: 19963522

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/26/07 10:36 AM, ID: 19964951

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/26/07 01:50 PM, ID: 19966651

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/26/07 02:34 PM, ID: 19966929

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/05/07 06:21 AM, ID: 20021582

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, .NET Framework 2.x, Visual Studio
Tags: dialog, excel, box, open, save
Sign Up Now!
Solution Provided By: ewesley
Participating Experts: 2
Solution Grade: B
 
 
[+][-]10/08/07 04:30 AM, ID: 20033216

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20090824-EE-VQP-74 / EE_QW_1_20070628