Exemple #1
0
        protected void rg1_ExcelMLExportRowCreated(object sender, GridExportExcelMLRowCreatedArgs e)
        {
            if (e.RowType == GridExportExcelMLRowType.DataRow)
            {
                if (!isConfigured)
                {
                    //Set Worksheet name
                    // e.Worksheet.Name = "Hoja";

                    //Set Column widths


                    foreach (ColumnElement column in e.Worksheet.Table.Columns)
                    {
                        if (e.Worksheet.Table.Columns.IndexOf(column) == 7)
                        {
                            column.Attributes["ss:Width"] = "180"; //set width 180 a columna Nombre
                        }
                        else
                        {
                            column.Attributes["ss:Width"] = "80"; //set width 80 al resto de columnas
                        }
                    }

                    //Set Page options
                    PageSetupElement pageSetup = e.Worksheet.WorksheetOptions.PageSetup;
                    pageSetup.PageLayoutElement.IsCenteredVertical   = true;
                    pageSetup.PageLayoutElement.IsCenteredHorizontal = true;
                    pageSetup.PageMarginsElement.Left           = 0.5;
                    pageSetup.PageMarginsElement.Top            = 0.5;
                    pageSetup.PageMarginsElement.Right          = 0.5;
                    pageSetup.PageMarginsElement.Bottom         = 0.5;
                    pageSetup.PageLayoutElement.PageOrientation = PageOrientationType.Landscape;

                    //Freeze panes
                    e.Worksheet.WorksheetOptions.AllowFreezePanes          = true;
                    e.Worksheet.WorksheetOptions.LeftColumnRightPaneNumber = 1;
                    e.Worksheet.WorksheetOptions.TopRowBottomPaneNumber    = 1;
                    e.Worksheet.WorksheetOptions.SplitHorizontalOffset     = 1;
                    e.Worksheet.WorksheetOptions.SplitVerticalOffest       = 1;

                    isConfigured = true;
                }
            }
        }
    protected void OnGridInvoiceExcelMLExportRowCreated(object source, GridExportExcelMLRowCreatedArgs e)
    {
        if (e.RowType == GridExportExcelMLRowType.DataRow)
        {
            //if (e.Row.Cells[0] != null && ((string)e.Row.Cells[0].Data.DataItem).Contains("U"))
            //{
            //    e.Row.Cells[0].StyleValue = "MyCustomStyle";
            //}
            //else
            //{

            //}
        }
        else if (e.RowType == GridExportExcelMLRowType.HeaderRow)
        {
            if (e.Row.Cells[0] != null)
            {
                e.Row.Cells[0].StyleValue = "MyCustomStyle";
            }
        }
    }