.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

Export DataGridView to excel

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :WPF


I've rowte this code to export to excel but i get a "COMException was unhandled" Exception from HRESULT : 0x800A03EC

Hope somone can helpe!



private void linieBindingNavigatorSaveItem_Click(object sender, EventArgs e)


    //DataTable dt = new DataTable("Line");

    private void Form1_Load(object sender, EventArgs e)
      // TODO: This line of code loads data into the 'betaToolDataSet.Linie' table. You can move, or remove it, as needed.

    private void btnExport_Click(objec

View Complete Post

More Related Resource Links

export datagridview to excel c#

 public static void Excel3(DataGridView dgv,string type)
      SaveFileDialog s_Lvl_Max =new SaveFileDialog(); 
      s_Lvl_Max.Filter = "xls files (*.xls)|*.xls|All files (*.*)|*.*"; 
      s_Lvl_Max.FilterIndex = 1;
      s_Lvl_Max.FileName = type+"_" + DateTime.Now.ToString("ddMMyyyy"); 
      s_Lvl_Max.OverwritePrompt = true; 

      if (s_Lvl_Max.ShowDialog() == DialogResult.OK) 
      Excel.Application oXL; 
      Excel._Workbook oWB;

        //Start Excel and get Application object. 
        oXL = new Excel.Application();
        oXL.Visible = false;
        oXL.DisplayAlerts = false;
        //Get a new workbook. 
        oWB = (Excel._Workbook)(oXL.Workbooks.Add(Missing.Value));
        oSheet = (Excel._Worksheet)o

How to export from DatagridView to Excel Sheet in C# Windows Forms



I am developing an application that loads a spreasheet to a datagrid, i then add a column (with data) dynamically in the datagrid. How can I take the data in the whole datagrid and display it in a new spreadsheet. Please help!

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.

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.

Export Gridview data to Excel sheet


Hi ,

     I have a requirement where i need to export the gridview data to excel.My code export the data in excel that was fine.

But the enchancement needed now , I was exporting the 3 gridview in same excel sheet under the workbook.

Now i need to export the 3 grid view in 3 different sheet in the same workbook.

so can please tell or share the updated code in my below code ...

public void writeovrsummary()


        Response.Write("Overall Summary");
        //Response.Write("Report as of " + DateTime.Now.ToString("hh:mm ss tt"));

        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);

        SqlCommand com = MyConnection.CreateCommand();
        com.CommandText = "useroverall_Report";
        SqlParameter[] par = new SqlParameter[1];
        par[0] = new

Export Dataset to excel sheet in a required format?



I know how to export a grid view to excel.

But here i have a Dataset which consists of data like below and also it need to display in a required format like below.

pno psubno pstate pdetailid pdetails

 12    1          CA         1           cbsdjcbdjc     

12     1          CA          2        cndcnjdcjcj

12     2           VA         4          xcndwkfcgygry

13     1            AL        1           ncdcnjdcndj

My excel sheet  should like this.

pid       pstate     

 12/1      CA             &nb

export to excel issue


Hello ,

I have a browser enabled form which i published to sharepoint ..now i want to export the contents of the form to excel..i have 1 repeating table and two repeating sections ..whenever i go to export to excel and then choose just one repeating table or a repeating section or any option other than export all form data i get an error ...first the progress bar just freezes and then when i end the task through task m anager i get a msg that microsoft excel could not start.make sure excel is installed correctly and then try again....

Can somebody tell me how to debug this..i have tried the export of a form containg repeating table and sections and it works good ..so that means there is some problem with my form..so now can somebody give me an idea as to what can the problem be and how can i debug it.


ASP.NET Excel Export Issue



I am trying to export data from SP to a .xlsx sheet. Total no of rows is more  than 15000 with total of 13 columns.The data is generated with the help of SQL Server SP. Till this point it is working fine. However while exporting to excel I do not get any data , the excel  has blank content.

If I have records less than 12000 it generated the excel report with  relevant data. However as row increases the report is blank.

Also the excel is generated through the code but when I deploy to server and try to generate it generates a blank excel. 

 Please advice what needs to be done. I have tried multiple options but none works.

Export altered gridview to Excel


Hello... stuck on this one!!  In a gridview RowDataBound named gvwResult I am altering one of the cells with a value retrieved from the query.

I have added:

if (hdnExchangeTo.Value.ToString() != "1")
            for (int i =0; i < gvwResult.Rows.Count; i++)
                gvwResult.Rows[i].Cells[7].Text = ExchangeCurrency(gvwResult.Rows[i].Cells[7].Text.ToString());

to the common code to export to Excel:

        Response.Buffer = true;
        Response.Charset = "";
        Response.ContentType = "application/vnd.ms-excel";
        System.IO.StringWriter sw = new Syste

How to do wide search and export the records to excel file in ASP.net C# ?


This is my MYSQL  database connection :-

public static OdbcConnection Connection = new OdbcConnection("Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=jdmcrm; User=root;Password=admin;");

My table name is "customer" and  fields liek customerId , companyName , address and date ;

How to do wide search and export the records to excel file ? im quite new in asp.net .

Pls advise . Thanks





Export to Excel

How can  I create hidden columns in SQL Server Reporting Services 2005 to be rendered as excel? Thanks in advance

VS2008 BIDS Report export to Excel not grouping the same as VS2005

I have a report that I created in VS2005 BIDS and got it to export to Excel to group/subtotal the same way it does in the BIDS report window.  Now I have copied the .rdl files to a VS2008 project, open it in VS2008 BIDS, made NO changes to the report format and the exported Excel file is combining what should be the 2nd and 3rd groups into 1 group.  In the BIDS window, the grouping is working correctly.  Does anyone have any ideas what has changed between 2005 & 2008 that may cause this problem?  Thanks in advance.    

String Data missing start from "+" When Export Data To Excel Using Gridview

Hi,I am exporting data from gridview to excel file.My problem is that for all the string which contain "+", the rest of data begining from it is missing in excel file.For example: PWE-WER+78, when exported it will become PWE-WER.Below is my code.                Response.ClearContent() Response.Buffer = True Response.AddHeader("Content-Disposition", "attachment;filename=" & "ExportedExcel.xls") Response.ContentType = "application/vnd.ms-excel" Response.Charset = "" lobjStringWriter = New StringWriter lobjHtmlWriter = New HtmlTextWriter(lobjStringWriter) dgdResult.RenderControl(lobjHtmlWriter) Response.Write(lobjStringWriter.ToString()) Response.End() I  have search through online but no solution.Does anyone has idea on this?

In export, i want to disable column in excel sheet

Hello, I am doing Import/Export. While export i want to disable some column in excel sheet, so during upload or import same primary key I can use, instead of user modify such column. Regards, Sandeep    

how to export the gridview1 in asp.net/c# into excel

i m having the datatable a        b12      1213       ukhdfukand how to export that to excel file.

Export to (pdf, excel, etc...)

I can't seem to find any support for exporting data to an excel file. Everything I have found regarding this topic refers to asp.net webform controls...Any suggestions?

Howe to do :Excel export button in report viewer visible false...?

hi all,  How I can do avoid to display  Excel export in ReportViewer..? if I Use //-------------------------- reportViewer1.ShowExportButton = false; //---------------------------------------------------- Both the buttons will be disabled...for only Excel button How can I...?    
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