Hello,
I have a WHDG that I'm trying to export via the WebExcelExporter. Below is my code. In Internet Explorer, when i click the button to download to excel, I see that the postback is firing the code but, the file that its trying to give me back is "default.aspx" and not the XLS file. When i try it on FireFox, I get the .XSL file to return but in opening the document, i see an empty grid. How do I send the WHDG as is (with out having to refresh the datasource) on the page to the explorter?
Below is my code.
/*********************** ASPX *************************/
<form id="form1" runat="server"> <ig:WebScriptManager ID="WebScriptManager1" runat="server" /> <div> <table> <tr> <td> <igmisc:WebGroupBox ID="WebGroupBox1" runat="server" Width="295px"> <Template> <table> <tr> <td style="width:85px;">Start Date : </td> <td style="width:140px;"><ig:WebDatePicker ID="WebStartDate" runat="server" /></td> <td style="width:60px"><igtxt:WebImageButton ID="WebImageButton1" runat="server" OnClick="Search" Text="Search"/></td> </tr> <tr> <td style="width:85px">End Date : </td> <td style="width:140px;"><ig:WebDatePicker ID="WebEndDate" runat="server" /></td> <td style="width:60px"><asp:Button runat="server" ID="btnExport" OnClick="btnExport_Click" /></td> </tr> </table> </Template> </igmisc:WebGroupBox> </td> </tr> <tr> <td> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always"> <Triggers> <asp:AsyncPostBackTrigger ControlID="WebGroupBox1$WebImageButton1" EventName="Click"/> </Triggers> <ContentTemplate> <ig:WebHierarchicalDataGrid ID="WHDG" runat="server" Height="800px" Width="1000px" InitialDataBindDepth="-1" EnableAjax="False" /> </ContentTemplate> </asp:UpdatePanel> </td> </tr> </table> </div> <ig:WebExcelExporter ID="WebExcelExporter1" runat="server" /> </form>
/*********************** CS *************************/
public partial class ACDVolume : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { using (XmlDataSource xmlDataSource = new XmlDataSource()) { xmlDataSource.XPath = @"/CallCenters/CallCenter"; xmlDataSource.EnableCaching = false; xmlDataSource.Data = GetCMS(WebStartDate.Text, WebEndDate.Text); WHDG.DataSource = xmlDataSource; WHDG.DataBind(); } } } public void btnExport_Click(object sender, EventArgs e) { this.WebExcelExporter1.WorkbookFormat = Infragistics.Documents.Excel.WorkbookFormat.Excel97To2003; this.WebExcelExporter1.Export(this.WHDG); } public void Search(Object sender, EventArgs e) { using (XmlDataSource xmlDataSource = new XmlDataSource()) { xmlDataSource.XPath = @"/CallCenters/CallCenter"; xmlDataSource.EnableCaching = false; xmlDataSource.Data = GetCMS(WebStartDate.Text, WebEndDate.Text); WHDG.GridView.ClearDataSource(); WHDG.DataSource = xmlDataSource; WHDG.DataBind(); } } private string GetCMS(string WebStartDate, string WebEndDate) { string strSQL = "dbo.dashboard_callcenter_metrix4"; string result = ""; using (SqlConnection connection = new SqlConnection("Server = 10.50.8.80;User ID = jpmc;Password = cstsqa;DATABASE = cstsdb")) { using (SqlCommand command = new SqlCommand(strSQL, connection)) { command.CommandTimeout = 0; command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@startDate", WebStartDate); command.Parameters.AddWithValue("@endDate", WebEndDate); using (DataTable dataTable = new DataTable()) { using (SqlDataAdapter dataAdapter = new SqlDataAdapter(command)) { dataAdapter.Fill(dataTable); } if (dataTable.Rows.Count > 0) { DataRow dataRow; for (int i = 0; i < dataTable.Rows.Count; i++) { dataRow = dataTable.Rows[i]; result += dataRow[0].ToString(); } } } } } return result; } }
Hi Shane,
Thank you for posting in the community.
There is a known issue with the excel exporter exporting the respective page's webform in volumes 11.1 and 11.2 which is currently awaiting release. I have linked your case with the work item related to this issue - 103548 and you will be notified when the fix is released.
Your support ticket regarding this matter is CAS-91298-1MCFW2. .Please feel free to continue sending us updates. You can view the status of the development issue connected to this case by going to the “My IG” tab on our website, hovering to the "My Support Activity" dropdown and selecting the "Development Issues" tab.
Do not hesitate to contact me if you need more information.
Hi Petar,
2 more questions:
1. Does 12.1 suffer from the same issue?2.. When i rename the file to an excel extension, when i open the file, the headers look as follows
Why am i getting #Name, #Value and #InnerText as fields in the excel file? The GRID that outputed this file looks like this:
The XML Looks like this:<LIST> <USER UserId="a123456" Names="Bob" Location="Tampa"> <CASE CaseId="2" Subject="case 2" CreatedDate="2012-03-02T00:00:00" Note="Bob's case" CreatorId="a123456" /> <CASE CaseId="3" Subject="Case 3" CreatedDate="2012-03-01T00:00:00" Note="Another" CreatorId="a123456" /> <CASE CaseId="5" Subject="Case5" CreatedDate="2012-03-03T00:00:00" Note="WTFFOO!" CreatorId="a123456"> <NOTE NoteId="3" WorkLog="Case 3 Log 1" /> </CASE> </USER> <USER UserId="b876204" Names="Shane" Location="Tampa"> <CASE CaseId="1" Subject="test case 1" CreatedDate="2012-03-01T00:00:00" Note="any text" CreatorId="b876204" /> <CASE CaseId="4" Subject="Case 4" CreatedDate="2012-03-02T00:00:00" Note="stuff" CreatorId="b876204" /> <CASE CaseId="6" Subject="Case 6" CreatedDate="2012-03-04T00:00:00" Note="Test Note" CreatorId="b876204"> <NOTE NoteId="1" WorkLog="test Log 1" /> <NOTE NoteId="2" WorkLog="Case 1 Log 2" /> </CASE> </USER></LIST>