Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
180
Exporting to Excel from a Modal Window
posted

Hello, 

The business requirements for my application require the use of modal windows due to the process involved in calculating commissions correctly.  The problem I'm having is exporting to Excel when <base target="_self"> is included in the head tag of the page.  Unfortunately, I've found that I need to include it in order for the grid to be grouped or ungrouped in the same window, the dialog window to be closed, or the grid to be updated in the same window (i.e., display a row in red when updated through a button).

In order to attempt to solve the problem, I've tried the various export modes along with a JavaScript function found when researching.  So far, nothing is working.  I've also changed to a modeless window and, although it works, I need to comply with the business requirements.

I would appreciate any help in getting grid results successfully exported to Excel from a modal window with <base target="_self"> in the head tag.  I'm including the definition of the grid and the code for exporting below.

Thanks and have a great day!

 Pat

<igtbl:UltraWebGrid ID="grdPreviewDetails" runat="server" Height="450px"

Width="797px" OnInitializeLayout="grdPreviewDetails_InitializeLayout"

onungroupcolumn="grdPreviewDetails_UnGroupColumn"

oninitializerow="grdPreviewDetails_InitializeRow">

<Bands>

<igtbl:UltraGridBand BaseTableName="grdPreviewDetails" Key="key">

<AddNewRow Visible="NotSet" View="NotSet"></AddNewRow>

<Columns>

<igtbl:UltraGridColumn BaseColumnName="key" HeaderText="" Hidden="True" Key="key">

<Header Caption="">

</Header>

</igtbl:UltraGridColumn>

<igtbl:TemplatedColumn AllowGroupBy="No" AllowUpdate="Yes" BaseColumnName="Checked"

HeaderText="" Key="Checked" SortIndicator="Disabled" Type="CheckBox">

<Header Caption="Hold?">

<RowLayoutColumnInfo OriginX="1" />

</Header>

<CellStyle HorizontalAlign="Center">

</CellStyle>

<Footer>

<RowLayoutColumnInfo OriginX="1" />

</Footer>

</igtbl:TemplatedColumn>

</Columns>

</igtbl:UltraGridBand>

</Bands>

<DisplayLayout Version="4.00" SelectTypeRowDefault="Extended" Name="grdPreviewDetails"

AllowSortingDefault="OnClient" AllowDeleteDefault="Yes"

AllowUpdateDefault="Yes" AllowColSizingDefault="Free" RowHeightDefault="20px"

TableLayout="Fixed" ViewType="OutlookGroupBy" RowSelectorsDefault="No"

AllowColumnMovingDefault="OnServer" HeaderClickActionDefault="SortMulti"

StationaryMargins="Header" BorderCollapseDefault="Separate"

StationaryMarginsOutlookGroupBy="True" CellClickActionDefault="RowSelect"

NoDataMessage="There are no payments to preview" IndentationDefault="0"

IndentationTypeDefault="Flat"

GroupByRowDescriptionMaskDefault="[caption] : [value] ([count]; [sum:AmountPaid])">

<GroupByBox>

<Style BackColor="ActiveBorder" BorderColor="Window"></Style>

</GroupByBox>

<FrameStyle BackColor="Window" BorderColor="InactiveCaption" BorderWidth="1px"

BorderStyle="Solid" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt"

Height="450px" Width="797px"></FrameStyle>

<ClientSideEvents AfterCellUpdateHandler="grdPreviewDetails_AfterCellUpdateHandler"

InitializeLayoutHandler="grdPreviewDetails_InitializeLayoutHandler" />

<Pager MinimumPagesForDisplay="2">

<Style BackColor="LightGray" BorderWidth="1px" BorderStyle="Solid">

<BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px"></BorderDetails>

</Style>

</Pager>

<EditCellStyleDefault BorderWidth="0px" BorderStyle="None"></EditCellStyleDefault>

<FooterStyleDefault BackColor="LightGray" BorderWidth="1px" BorderStyle="Solid">

<BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px"></BorderDetails>

</FooterStyleDefault>

<HeaderStyleDefault HorizontalAlign="Left" BackColor="LightGray" BorderStyle="Solid">

<BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px"></BorderDetails>

</HeaderStyleDefault>

<RowStyleDefault BackColor="Window" BorderColor="Silver" BorderWidth="1px" BorderStyle="Solid">

<Padding Left="3px"></Padding>

<BorderDetails ColorLeft="Window" ColorTop="Window"></BorderDetails>

</RowStyleDefault>

<GroupByRowStyleDefault BackColor="Control" BorderColor="Window"></GroupByRowStyleDefault>

<AddNewBox Hidden="False">

<Style BackColor="Window" BorderColor="InactiveCaption" BorderWidth="1px" BorderStyle="Solid">

<BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px"></BorderDetails>

</Style>

</AddNewBox>

<FilterOptionsDefault>

<FilterDropDownStyle CustomRules="overflow:auto;" BackColor="White" BorderColor="Silver" BorderWidth="1px" BorderStyle="Solid" Font-Names="Verdana,Arial,Helvetica,sans-serif" Font-Size="11px" Height="300px" Width="200px">

<Padding Left="2px"></Padding>

</FilterDropDownStyle>

<FilterHighlightRowStyle BackColor="#151C55" ForeColor="White"></FilterHighlightRowStyle>

</FilterOptionsDefault>

</DisplayLayout>

</igtbl:UltraWebGrid>

<div id="divExport" style="z-index: 107; left: 12px; width: 479px; position: absolute;

top: 566px; height: 53px">

<cc1:UltraWebGridExcelExporter ID="UltraWebGridExcelExporter1" runat="server"

EnableViewState="false" oninitializecolumn="UltraWebGridExcelExporter1_InitializeColumn" >

</cc1:UltraWebGridExcelExporter>

</div>

 

protected void btnExportPreview_Click(object sender, EventArgs e)

{

string strYear = System.DateTime.Today.Year.ToString();

string strMonth = System.DateTime.Today.Month.ToString();

string strDay = System.DateTime.Today.Day.ToString();

//Add leading zero if month is single digit

if (strMonth.Length == 1)

{

strMonth =
"0" + strMonth;

}

//Add leading zero if day is single digit

if (strDay.Length == 1)

{

strDay =
"0" + strDay;

}

string strFileName = "PaymentPreview_" + strYear + strMonth + strDay + ".xls";

grdPreviewDetails.Columns.FromKey("AmountPaid").HeaderText = "Payment";

grdPreviewDetails.Columns.FromKey("AmountPaid").Format = "C"; //To ensure the export retains the currency format, set the value to "C" here; it is checked/set in the InitializeColumn function.

grdPreviewDetails.Columns.FromKey("IsHeld").Hidden = true;

UltraWebGridExcelExporter1.DownloadName = strFileName;

UltraWebGridExcelExporter1.ExportMode = Infragistics.WebUI.UltraWebGrid.ExcelExport.ExportMode.InBrowser;

UltraWebGridExcelExporter1.Export(grdPreviewDetails); //,strFileName

}

Parents Reply Children
No Data