Web Forms :: Does Exporting DataGridView To Excel Has Limitations Of Columns Or Column Types

May 7, 2015

I am trying to export my Model to an Excel sheet. I have 31 fields out of which only 29 are exported. Among the 3 fields that I am not able to export 2 are of type Enum and one of DateTime. Their is another DateTime field also, but that is exported properly. Here are few fields of the model :

[EnumDataType(typeof(Suffix)), Display(Name = "Suffix *")]
[Required(ErrorMessage = "Suffix is Required")]
public Suffix NameSuffix { get; set; }
[EnumDataType(typeof(InquiryStatus)), Display(Name = "Status")]
[Required(ErrorMessage = "Status is Required")]

[Code] ....

Among the 4 fields above, NameSuffix, Inquiry_Status & FollowUpDate are not exported. InquiryDate is exported.

My exporting code is :

DataGrid dg = new DataGrid();
dg.DataSource = inqs.ToList<Inquiry>();
dg.DataBind();
string filename = "InquiryList_" + DateTime.Now + ".xls";
Response.ClearContent();

[Code] ....

In the ContentType, I alos tried with ""application/ms-excel";, but that makes no difference.

What can be the error for the above ?

View 1 Replies


Similar Messages:

Forms Data Controls :: Exporting 3.5 DataGridView To Excel

Feb 2, 2011

I am trying to export an ASP.NET 3.5 DataGridView to Excel using the following code :

protected
void Button1_Click(object sender,
EventArgs e)
{
Response.Clear();
Response.Buffer = true ;
Response.AddHeader("content-disposition" ,
"attachment;filename=text.xls" );
Response.Charset = "" ;
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ;
StringWriter sw =
new StringWriter ();
HtmlTextWriter hw =
new HtmlTextWriter (sw);
GridView1.DataSource = RecordsDataSet;
GridView1.DataBind();
GridView1.AllowPaging = false ;
GridView1.DataBind();
GridView1.HeaderRow.Style.Add("background-color" ,
"#FFFFFF" );
for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridViewRow row = GridView1.Rows[i];
//Change Color back to white
row.BackColor = System.Drawing.Color .White;
//Apply text style to each Row
row.Attributes.Add("class" ,
"textmode" );
}
GridView1.RenderControl(hw);
//style to format numbers to string...........

View 10 Replies

Databases :: Exporting Data Into Excel In Columns?

Aug 12, 2010

i did the mysql data export into excel in row wise when button click... here i want the same data export into columns wise..i used datatable and dataset for this function.. here i need all data should export in column..here i used some code..

[Code]....

View 2 Replies

Web Forms :: To Use Response.Write To Adjust Column Widths When Exporting Data To MS Excel?

Feb 14, 2010

Is there a simple way to use Response.Write to adjust column widths when exporting data to MS Excel?

View 3 Replies

Data Controls :: Add Custom Column While Exporting Excel From GridView

May 7, 2015

I am able to save excel sheet from GridView perfectly. However, I need to add one custom column, which will be URL of a file on sever, I am not allowed to add URLs directly in the table (as per company's development policies). I tried pulling URL from web.config however I am not sure where to add that in the following code

<asp:GridView ID="bestpractgrv" runat="server" AutoGenerateColumns="False" CellPadding="3" GridLines="Vertical" Width="100%" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" PageSize="10" AllowPaging="True" OnPageIndexChanging="OnPaging" DataKeyNames="iID">
<AlternatingRowStyle BackColor="Gainsboro" />
<Columns>

[code]....

View 1 Replies

C# - Exporting Data To Excel, With Jagged Columns Due To Dynamic Data?

Jan 25, 2010

I have a bit of an interesting problem where I need to create an Excel data dump from some data in the database, but rather than it being something simple I have some complex data to merge, below is an example of the data that I have to deal with.

TblGeneralInfo

RecordId|Record Name |Date |Cost
1 |Test Entry | 1/1/2010 |2.0
2 |Test Entry2 | 1/1/2010 |20.25

TblRandomInfo

RecordId |QuestionName | Answer
1 |Your Name? | Bob
1 |Your Title? | The Builder
2 |Favorite Movie | The Matrix
2 |Favorite Car | Mustang


What I need in the end is the following

RecordId|Record Name |Date |Cost | | | |
1 |Test Entry | 1/1/2010 |2.0 |Your Name? | Bob | Your Title? | The Builder
2 |Test Entry2 | 1/1/2010 |20.25 |Favorite Move | The Matrix | Favorite Car | Mustang

Now I'm using SQL Server 2005 for the reporting and ASP.NET 3.5 (C#) for the application. I'm looking for the best way to do this. The number of items in "tblRandomInfo" is variable, and can have as many as 20-30 Q/A pairs per record. I cannot easily do a pivot, even a dynamic pivot due to the nature of the data.

Edit.A solution is valid either on the SQL Server or C# side. But note that information in tblRandomInfo can contain line breaks.

View 3 Replies

Forms Data Controls :: Exporting Gridview Into Excel Is Not Generating The Result On Excel File?

Apr 1, 2010

when I used a code of exporting gridview into excel this code worked for a new website which is without masterpage.

my code:

public override void VerifyRenderingInServerForm(Control control) { }
protected void BtnGenerateReport_Click(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition",
"attachment;filename=GridViewExport.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();.....

Now the same code when I copy it in my project having masterpage . there is no compiler error but it is genereating excel file withno data in it but in fact there is data in the grid view at runtime.

View 2 Replies

Data Controls :: Exporting GridView To Various File Types?

Sep 11, 2012

Exporting the GridView to various file types.  I have got the PDF working great and also want to add Excel.  When I use the code I get a message that the file I am trying to open is a different file format from the extension I am trying to open.  If i click OK it opens and alls is fine.  Trying to get rid of this errors so customers and sales staff doesn't see it.  Excel is version 2010.

View 1 Replies

Forms Data Controls :: How To Freeze Two Columns In Datagridview

Aug 26, 2010

I have a situation where I need to freeze first two colums in a datagrid view control on my asp.net app. In windows forms there is a proprty called Freeze which can be enabled / disabled. How can I freeze first two colums in a data grid view control on my ASP.NET page.

View 1 Replies

Visual Studio :: Exporting A .rdlc To Excel / Analagous Export Of That Report To Excel?

Nov 2, 2010

I've got an .rdlc report which I print from my .net app (C# Visual Studio 2005), where I use a RemoteReportPrinter object. I give it as parameters the server name, report name, report parameters, etc. Works fine. My question is, I would live to do an analagous export of that report to Excel. Set it up exactly the same, but have it export to Excel rather than print, probably using some other type of object than RemoteReportPrinter.

View 1 Replies

Data Controls :: How To Add Header To Excel On Exporting Gridview To Excel Sheet

Feb 28, 2013

I'm exporting a Gridview to excel. I get all the gridview header and content in excel in addition to that i need to add a header text like report name in header of the excel sheet with line break in header.

I tried the solution in this link [URL] by adding

Table.Caption = "Header Text"
Table.CaptionAlign = TableCaptionAlign.Top
but i get error Reference to a non shared member requires an object reference.

View 1 Replies

Data Controls :: Exporting GridView To Excel / Whole Excel Is Empty

Oct 17, 2013

I have a project in vb with a gridview in a multiview and i want to save in a workbook excel the gridview displayed data. I have read many articles but in the end i have downloaded the code from URL...and i adapted for my code. The problem is that when i press the ExporttoExcel button it's exporting only this...I cannot figure out that is the problem.

<style> .textmode { mso-number-format:@; } </style><div>

</div>

My code is down

Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls.TableRow
Imports System.Web.UI.WebControls.GridViewRow
Imports System.Diagnostics
Imports System.IO
Imports System.Configuration

[code]....

View 1 Replies

Forms Data Controls :: Datagridview Control With Dynamically Added BoundField Columns?

Jun 2, 2010

I am having datagridview control with dynamically added BoundField columns.I want to have tetxboxes in each cell of the gridview so taht user will enter data in gridview textboxes and at last on button click it will be saved in database.

View 14 Replies

Web Forms :: Exporting Multiple HTML Tables To Multiple Excel Sheets Excel

Mar 30, 2010

is there any way that i could export multiple tables already formatted into multiple excel sheets. I know how to export data to multiple sheets through dataset while looping through tables, rows and columns and then add styles.

But I really want to export formatted html tables each into seperate sheet

View 3 Replies

Web Forms :: Exporting A Gridview To Excel?

Jan 4, 2011

On two of my web forms I have the ability to export a gridview to an excel file. On my local machine. it works. So when I click an image button it gives me the option of opening or saving a gridview as Excel.

However, when I run on the web server. It does not give me the option to open or save, it just opens the gridview as an excel document when the button is clicked.

Even stranger: I have this running on two separate forms. On one form when it opens the gridview as an Excel file it includes a tool bar, so that If a user wishes they could do a 'file', 'save'; However the other one does not have a tool bar?

Ideally I would like them to get the prompt like on the local machine, to open or save.

View 7 Replies

Forms Data Controls :: Dynamically Add New Column To A Datagridview?

Feb 15, 2011

I have calculated a value (say, Total) from datagrid values using RowDataBound event.

I want to show the value by adding a new column into Grid.

View 6 Replies

Web Forms :: Currency Formatting When Exporting To Excel?

May 5, 2010

I'm exporting data to Excel but where the currency values are formatted I get an  before the currency symbol.

Here is my code:

[Code]....

View 8 Replies

Web Forms :: Removing Links When Exporting To Excel

Jan 20, 2012

URL...I now want to turn off all hyperlinks that are in the gridview.  How do I do that with this code?

 Button on page<asp:Button ID="Button2" runat="server" Text="Export to Excel"
OnClick="BtnExportExcel_Click" Font-Names="Arial" style="text-align: center" />
Code behind: Public Overloads Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
' Verifies that the control is rendered
End Sub
otected Sub BtnExportExcel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

[code]....

View 1 Replies

Web Forms :: Remove Links When Exporting To Excel?

Feb 7, 2012

What am I missing because when my gridview exports the Area (DataTextField) column still has the links although I have a function to remove the links:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" EnableModelValidation="True" Width="856px" CaptionAlign="Top" Height="126px" BackColor="White" BorderColor="#DCBE68" BorderStyle="Solid" BorderWidth="1px"

[Code].....

View 1 Replies

Web Forms :: Exporting Page To Excel 2007

Apr 11, 2012

 I need to export asp.net page toexcel 2007. when i wrote the code as below:

protected void Button2_Click(object sender, EventArgs e) {Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = ""; Response.ContentType = "application/vnd.xls"; System.IO.StringWriter string
Write = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter html
Write = new HtmlTextWriter(stringWrite); div1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString()); Response.End(); } 
publicoverride void VerifyRenderingInServerForm(Control control) {   
} and

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="poprint.aspx.cs" Inherits="print_poprint" EnableEventValidation="false" %>

It displays message as shown

The file you are trying to open is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?

When yes is clicked it opens in excel but in some other format I think for I cannot AUTOSUM or sum the values result always as zero for numbers appears as text as " 222" . even if i try to format cells with numbers it does not works.

View 1 Replies

Forms Data Controls :: Set Datagridview Items Column Width?

Apr 5, 2010

I am using C# , ASP .NET 2.0 and i have to avoid the datagrid view items from being wrapped.

View 4 Replies

Web Forms :: Exporting Asp.net4.0 Chart Data To Pdf/Excel

Aug 10, 2010

let me know how to export asp.net4.0 chart data to pdf/excel .

View 2 Replies

Web Forms :: Exporting To Excel - Get The Number To Show Up As Numeric?

Oct 26, 2010

I have a report which is created using a .rdlc. And populated using a List object. The report when exported to excel has a problem. The numeric colums show up as text and the tooltip in excel says "The number in this cell is formatted as text or preceded by an apostrophe". How can I get the number to show up as numeric?

View 1 Replies

Web Forms :: Exporting Entire Page To Excel. Getting An Error?

Jun 24, 2010

This is an ASP.NET web app built using VS2008. I created a standalone class with a method that exports the entire page, text fields, gridviews, images, everything to an Excel worksheet. It works fine. When I dropped the same class in another web app and tried to call it from a page, I get this error message:

[Code]...

View 8 Replies

Web Forms :: Is It Possible To Redirect To Another Website After Exporting A Datagrid To Excel

May 7, 2010

Is it possible to redirect to another website after Exporting a datagrid to Excel?

Right now I have code that goes a little something like this

Response.ClearHeaders();

Response.ContentType = "application/ms...";

/* write to an Excel file through streams */

Response.Redirect("newpage.aspx");

That is the basic idea of my code.

This doesn't work because I can't redirect after clearing the header or changing the content type.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved