.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Redirect the output to excel

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :ASP.Net

Currently  I have a ASP page that brings data from the database and display in a grid, something like this

     DataSet dsReport = sqlServer.GetReports ((txtbox1.Text), dropdownlist1.SelectedValue,dteDue);
            DataGrid1.DataSource = dsReport.Tables[0];


what i want is instead of data in a data grid display have it in a excel file  so I used

RenderExcel(dsReport.Tables[0], strFileName);

But instead of getting the data from the database in the excle file. I get the input asp page displayed in the excel. Pleae can anybody suggest what to do?


Thanks in advance







View Complete Post

More Related Resource Links

What does Error Output option "Redirect Row" do?

I'm reading this http://technet.microsoft.com/en-us/library/ms141679(SQL.90).aspx but I don't quite understand about the Error Output option "Redirect Row", the error or the truncation data row is directed to the error output of the source, transformation, or destination. It sounds to me that the error will be output to somewhere but how I know where.  In the Advance Editor for Destination, I find the Input and Output Properties and it has Output Columns under OLE DB Destination Error Output. For example, if I set the Error Output option to "Redirect Row" for a Destination component, what does it mean?  Is there any article which shows an example of "Redirect Row"?    

Output data grid as excel

Hi,I'm trying to output a data grid as excel when someone clicks a button on a web page.I have the data grid working and have found some code to do the excel output, but can't quite get it working.  The code is like this:using System; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Collections.Generic; using System.Linq; using System.IO; using System.Web; using System.Web.UI; using umbraco; namespace MyDataExport { public partial class ExportData : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindGrid(); } } private void BindGrid() { SqlDataReader reader; SqlConnection conn = new SqlConnection(GlobalSettings.DbDSN); SqlCommand comm = new SqlCommand("SELECT * FROM budgetData;", conn); try { conn.Open(); reader = comm.ExecuteReader(); GridView1.DataSource = reader; GridView1.DataBind(); reader.Close(); } finally { conn.Close(); } } private void btnExportToExcel_Click(object sender,System.EventArgs e) { ExportToExcel("Report.xls", DataGrid1); //This line is erroring, saying 'DataGrid1 does not exist in the current context' } private void ExportToExcel(string strFileName, DataGrid dg) //This line errors, saying 'The type or namespace name DataGrid c

Output table from database to excel spreadsheet asp.net c#

Hi All, I'm hoping someone can help me with a small problem. I want to output some data returned from a sql server database and output it out to an excel file. My thinking was to create some excel templates, copy the required one that I want to use and output the data to that. I can pull the data back from the database OK, but have no idea how to write this to the excel spreadsheet. I want to try and keep the code as generic as possible so that I can use it to output a resultset to the correct copied template. Any help or pointers would be greatly appreciated.

hyperlink in Excel and login redirect


The user has a .xlsx with links pointing to a portal page witch require user logon.

First time (clicking on a link) the login.aspx?ReturnUrl=... is displayed, as expected. User logs in.

Second time, login.aspx?ReturnUrl=... displayed again, wrongly, bec user is already loged on.

It's seems, Excel calls the original link directly, server redirects (bec, excel is not loged in), than excel lunch the browser with new redirected url.

I can't simply redirect the user automatically, bec login.aspx is displayed also when the user has no permmissons.

What can I do?


Redirect To Excel


 I have something like this in my code


private void LoadData()
            string value = cboCarrierCode.SelectedValue;
            DateTime dteDue = new DateTime(int.Parse(Request.Form["txtYYYY"]),
            string strFileName = "nsl_";
            strFileName += (cboDealers.SelectedValue).ToString();
            strFileName += ".xls";
            DataSet dsReport = sqlServer.GetReportsForNewReportsPage

Error output in OLE DB Destination. How to redirect a row?





when I'm trying to redirect a row I'm having the following error:


Error 4 Validation error. Data Flow Task: OLE DB Destination [535]: The error row disposition on "input "OLE DB Destination Input" (548)" cannot be set to redirect the row when the fast load option is turned on, and the maximum insert commit size is set to zero. PCKG_MPP.dtsx

Can somebody help me?

Problem redirect debug output to a file using trace listener


I have created a debug listener to redirect the output from the Debug/Console window to a file(with a call stack), using the following code:

void SomeMethod()
    // Create a file for output .txt.
    Stream debugFile = File.Create(fileName);

    // create TextWriterTraceListener named "file"
    TextWriterTraceListener debugWriter = new TextWriterTraceListener(debugFile, "file");

    // add to debug listeners
    // set callstack to be shown
    Debug.Listeners["file"].TraceOutputOptions |= TraceOptions.Callstack;
    // set auto-flush
    Debug.AutoFlush = true;

but the output won't redirect to the file I specified, it is always empty. I am calling this from the constructor in my main form. Is the place where I'm calling it from a problem?

What I am trying to achieve here is to have the exceptions from the Debug output window placed in a file with a call stack, so that I can find them and correct them.

Anyone have any ideas?

Bojan Skr

Export Visio Database Table Names to Excel

If you use the Enterprise Architect edition of Microsoft Visio for data modeling regularly, then there is a good chance that at some point you've wanted to export just the table names into Excel. You might want to do this to map logical ERD entities to physical data model tables, track project status by entity, or track overlap between database versions.

Excel Automation in .Net

Excel Automation is a buzz word in both webapps and winapps. In the programming life (like Mr.Anderson neo) I guess almost every one could have come across this word. For others let me go further in detail. Excel Automation is automating some or all of the process involved in creating or updating excel worsheets.

display data into GridView from excel sheet

I have to display data from excel sheet into my gridview and also I need to figure out a way to store data into excel files from my web page. I am using C# 3.5, VS 2008.

Export SharePoint List to Excel Spreadsheet Programmatically using C#

In SharePoint applications, Custom Lists are used to store business data and Document Libraries to store the documents. But for data manupulation and analysis, Microsoft Excel provides very rich features as compared to SharePoint Lists. That's why people still loves to work on Microsoft Excel Sheets.

Creating an Excel Spreadsheet programmatically using VB.NET

The Interoperability services make it very easy to work with COM Capable Applications such as Word and Excel. This article reveals using Excel from a managed application. Excel is the spreadsheet component of Microsoft Office 2000. The majority of Excel programmatic functionality is exposed through Automation via the type library Excel9.olb. The intention of this article is to express that a managed application can interrelate with Excel as a COM server.

Create And Run Excel Macro At Runtime in C#

You've been tasked with writing a Windows Form application using the .NET Framework that interacts with Microsoft Excel. If you are new to working with Excel in .NET and are having trouble learning how to format certain cells or cell ranges, then this little tip will come in handy. Rather than scour the internet hoping to find the correct set of constants or method syntax for formatting your spreadsheet, use the built in tools in Excel to write the familiar VBA code for you. Then, you can paste the VBA code generated by Excel into the sample C# code below and run it dynamically at runtime.

Creating an Excel Spreadsheet and Adding Data to It Programmatically

The Interoperability services make it veryeasy to work with COM Capable Applications such as Word and Excel. Thisarticle reveals using Excel from a managed application. Excel is thespreadsheet component of Microsoft Office 2000. The majority of Excelprogrammatic functionality is exposed through Automation via the typelibrary Excel9.olb. The intention of this article is to express that amanaged application can interrelate with Excel as a COM server.

Creating Excel file from C#

I used below coding for create a excel sheet.I got from on web site.
In below coding there is no problem.Its create the excel file.If i run second time,its ask to overwrite the current excel file.If I said "Yes" then it ok ,but If I select cancel button,its generate the Error message.The exception is

Gridview that exports selected rows to Excel

his seems like a messy workaround, but I ended up using two Gridviews - one to display my data and show my checkboxes, and the other which was invisible amd would eventually end up as my Excel spreadsheet.

Comma-Delimited Output

One of the common tasks performed when retrieving data from a SQL Server database is returning the result as a comma-delimited output instead of a result set. This task can be performed by using a CURSOR selecting the column to be concatenated together. Each row returned by the CURSOR is then concatenated together into a variable separating each one by a comma.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend