hi everyone, so here I'm trying to export a WebDataGrid, but when I click on the export, the excel is empty and only the column name are appeared, here is my code:
Imports Infragistics.Web.UI.GridControls Public Class atte Inherits System.Web.UI.Page Protected Sub Generate_btn_Click(sender As Object, e As EventArgs) Handles Generate_btn.Click Dim ds As New DataSet3 Dim dt As DataTable = ds.DataTable1 For i As Integer = 1 To 10 dt.Rows.Add(i) Next WebDataGrid1.DataSource = dt WebDataGrid1.DataBind() End Sub Private Sub WebDataGrid1_InitializeRow(sender As Object, e As RowEventArgs) Handles WebDataGrid1.InitializeRow e.Row.Items.FindItemByKey("Type").CssClass = "TestCss" End Sub Protected Sub Export_btn_Click(sender As Object, e As EventArgs) Handles Export_btn.Click WebExcelExporter1.Export(WebDataGrid1) End Sub End Class
so I did a workaround and added the generate code before the export function, exported the data successfully but without any style.
Protected Sub Export_btn_Click(sender As Object, e As EventArgs) Handles Export_btn.Click Dim ds As New DataSet3 Dim dt As DataTable = ds.DataTable1 For i As Integer = 1 To 10 dt.Rows.Add(i) Next WebDataGrid1.DataSource = dt WebDataGrid1.DataBind() WebExcelExporter1.Export(WebDataGrid1) End Sub
any help for both issues?
thanks
Hello,
Thank you for contacting us!
I've created a sample based on your configuration and the styles are exported as expected, please do have a look. As you shared only your code behind, I am unable to determine whether the Initialize_rows is handled appropriately. Could you please make sure that it is bound on page_load, or though the Grid markup.
In order to run the sample, please make sure that there is a styleset file in the ig_res folder.
Looking forward to your reply.
WDGStylesExport.zip
thank you for your support,
first of all, I've followed your instructions, but still the same issue, exported without the data and without style, and also I didn't find the Styleset file in the ig_res folder! how I can get it?
and here is my code behind and the asp.net markup
Imports Infragistics.Web.UI.GridControls Public Class atte Inherits System.Web.UI.Page Protected Sub Generate_btn_Click(sender As Object, e As EventArgs) Handles Generate_btn.Click WebDataGrid1.DataSource = populate() End Sub Private Sub WebDataGrid1_InitializeRow(sender As Object, e As RowEventArgs) Handles WebDataGrid1.InitializeRow e.Row.Items.FindItemByKey("Name").CssClass = "TestCss" End Sub Protected Function populate() As DataTable Dim dt As DataTable = New DataTable() dt.Columns.Add("Name") Dim row As DataRow For i As Integer = 0 To 10 - 1 row = dt.NewRow() row.SetField(Of String)("Name", "Name" & i) dt.Rows.Add(row) Next Return dt End Function Protected Sub Export_btn_Click(sender As Object, e As EventArgs) Handles Export_btn.Click WebExcelExporter1.Export(WebDataGrid1) End Sub End Class
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="atte.aspx.vb" Inherits="HR_System.atte" %> <%@ Register assembly="Infragistics45.Web.v18.2, Version=18.2.20182.305, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.Web.UI.GridControls" tagprefix="ig" %> <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"> <style type="text/css"> .TestCss{background-color: Red !important;} </style> <ig:WebExcelExporter ID="WebExcelExporter1" runat="server"> </ig:WebExcelExporter> <ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="100%" /> <asp:Button ID="Generate_btn" runat="server" Text="Generate" /> <asp:Button ID="Export_btn" runat="server" Text="Export" /> </asp:Content>
the result on the application
the exported data