Exemplo n.º 1
0
    /// <summary>
    /// Export handler.
    /// </summary>
    protected void lnkExportToExcel_Click(object sender, EventArgs e)
    {
        UniGridExportHelper export = new UniGridExportHelper(gridValidationResult);

        export.ExportRawData  = false;
        export.GenerateHeader = true;
        export.FileName       = ValidationHelper.GetSafeFileName("CSSValidation_" + ((Node != null) ? Node.DocumentNamePath : Url) + "_" + DateTime.Now.ToString()).Replace(" ", "_");
        export.ExportData(DataExportFormatEnum.XLSX, Page.Response);
    }
    /// <summary>
    /// Exports data based on given format.
    /// </summary>
    /// <param name="format">Format to export data in</param>
    /// <param name="forceMaxItems">Max items count (for preview export)</param>
    private void ExportData(DataExportFormatEnum format, int?forceMaxItems = null)
    {
        UniGridExportHelper.ExportRawData   = chkExportRawData.Checked && UserCanEditSql;
        UniGridExportHelper.CSVDelimiter    = CurrentDelimiter;
        UniGridExportHelper.GenerateHeader  = chkExportHeader.Checked;
        UniGridExportHelper.CurrentPageOnly = chkCurrentPageOnly.Checked;
        UniGridExportHelper.Records         = ValidationHelper.GetInteger(txtRecords.Text, -1);

        // Preview export
        if (forceMaxItems != null)
        {
            int limit;

            if (UniGridExportHelper.CurrentPageOnly)
            {
                limit = UniGrid.Pager.DisplayPager ? UniGrid.Pager.CurrentPageSize : 0;
            }
            else
            {
                limit = UniGridExportHelper.Records;
            }
            if ((limit >= forceMaxItems) || (limit <= 0))
            {
                UniGridExportHelper.Records         = forceMaxItems.Value;
                UniGridExportHelper.CurrentPageOnly = false;
            }
        }

        // Get order by clause from correct control
        if (!chkCurrentPageOnly.Checked)
        {
            UniGridExportHelper.OrderBy        = UserCanEditSql ? TrimExtendedTextAreaValue(txtOrderBy.Text) : ValidationHelper.GetString(orderByElem.Value, null);
            UniGridExportHelper.WhereCondition = UserCanEditSql ? TrimExtendedTextAreaValue(txtWhereCondition.Text) : String.Empty;
        }
        UniGridExportHelper.Columns = GetSelectedColumns();

        if (UIContext.SiteID > 0)
        {
            UniGridExportHelper.SiteName = SiteInfoProvider.GetSiteName(UIContext.SiteID);
        }
        else if (IsCMSDesk)
        {
            UniGridExportHelper.SiteName = SiteContext.CurrentSiteName;
        }

        UniGridExportHelper.ExportData(format, Page.Response);
    }
Exemplo n.º 3
0
    /// <summary>
    /// Exports data based on given format.
    /// </summary>
    /// <param name="format">Format to export data in</param>
    /// <param name="forceMaxItems">Max items count (for preview export)</param>
    private void ExportData(DataExportFormatEnum format, int?forceMaxItems = null)
    {
        UniGridExportHelper.ExportRawData   = chkExportRawData.Checked;
        UniGridExportHelper.CSVDelimiter    = CurrentDelimiter;
        UniGridExportHelper.GenerateHeader  = chkExportHeader.Checked;
        UniGridExportHelper.CurrentPageOnly = chkCurrentPageOnly.Checked;
        UniGridExportHelper.Records         = ValidationHelper.GetInteger(txtRecords.Text, -1);

        // Preview export
        if (forceMaxItems != null)
        {
            int limit = 0;
            if (UniGridExportHelper.CurrentPageOnly)
            {
                limit = UniGrid.Pager.DisplayPager ? UniGrid.Pager.CurrentPageSize : 0;
            }
            else
            {
                limit = UniGridExportHelper.Records;
            }
            if ((limit >= forceMaxItems) || (limit <= 0))
            {
                UniGridExportHelper.Records         = forceMaxItems.Value;
                UniGridExportHelper.CurrentPageOnly = false;
            }
        }

        UniGridExportHelper.UseGridFilter = chkUseGridFilter.Checked;
        // Get order by clause from correct control
        if (MembershipContext.AuthenticatedUser.IsGlobalAdministrator)
        {
            UniGridExportHelper.OrderBy = TrimExtendedTextAreaValue(txtOrderBy.Text);
        }
        else
        {
            UniGridExportHelper.OrderBy = ValidationHelper.GetString(orderByElem.Value, null);
        }
        UniGridExportHelper.WhereCondition = TrimExtendedTextAreaValue(txtWhereCondition.Text);
        UniGridExportHelper.Columns        = GetSelectedColumns();
        if (IsCMSDesk)
        {
            UniGridExportHelper.SiteName = SiteContext.CurrentSiteName;
        }
        UniGridExportHelper.ExportData(format, Page.Response);
    }
 /// <summary>
 /// Export handler.
 /// </summary>
 protected void lnkExportToExcel_Click(object sender, EventArgs e)
 {
     UniGridExportHelper export = new UniGridExportHelper(gridValidationResult);
     export.ExportRawData = false;
     export.GenerateHeader = true;
     export.FileName = ValidationHelper.GetSafeFileName("HTMLValidation_" + ((Node != null) ? Node.DocumentNamePath : Url) + "_" + DateTime.Now.ToString()).Replace(" ", "_");
     export.ExportData(DataExportFormatEnum.XLSX, Page.Response);
 }