Ejemplo n.º 1
0
 protected void RadGrid1_BiffExporting(object sender, GridBiffExportingEventArgs e)
 {
     xls.Table tbl = e.ExportStructure.Tables[0];
     //tbl.Rows[1].Height = 30;
     tbl.Columns[1].Width = 25;
     tbl.Columns[1].Style.HorizontalAlign = HorizontalAlign.Left;
     tbl.Columns[2].Width = 25;
     tbl.Columns[2].Style.HorizontalAlign = HorizontalAlign.Left;
     tbl.Columns[3].Width = 25;
     tbl.Columns[3].Style.HorizontalAlign = HorizontalAlign.Left;
     tbl.Columns[4].Width = 35;
     tbl.Columns[4].Style.HorizontalAlign = HorizontalAlign.Left;
 }
Ejemplo n.º 2
0
    private void GenerateTable(RadGrid grid, xls.Table singleTable)
    {
        if (ExportingType.SelectedValue == "1")
        {
            singleTable = new xls.Table(grid.ID);
            row         = 1;
            col         = 1;
        }
        else
        {
            if (!isFirstItem)
            {
                row++;
            }
            else
            {
                isFirstItem = false;
            }
        }

        GridHeaderItem headerItem = grid.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem;

        for (int i = 2; i < headerItem.Cells.Count; i++)
        {
            singleTable.Cells[i - 1, row].Value = headerItem.Cells[i].Text;
        }

        row++;

        foreach (GridDataItem item in grid.MasterTableView.Items)
        {
            foreach (GridColumn column in grid.Columns)
            {
                singleTable.Cells[col, row].Value = item[column.UniqueName].Text;
                col++;
            }
            col = 1;
            row++;
        }

        if (ExportingType.SelectedValue == "1")
        {
            structure.Tables.Add(singleTable);
        }
    }
    private void GenerateTable(RadGrid grid, xls.Table singleTable)
    {
        if (ExportingType.SelectedValue == "1")
        {
            singleTable = new xls.Table(grid.ID);
            row = 1;
            col = 1;
        }
        else
        {
            if (!isFirstItem)
                row++;
            else
                isFirstItem = false;
        }

        GridHeaderItem headerItem = grid.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem;

        for (int i = 2; i < headerItem.Cells.Count; i++)
        {
            singleTable.Cells[i - 1, row].Value = headerItem.Cells[i].Text;
        }

        row++;

        foreach (GridDataItem item in grid.MasterTableView.Items)
        {
            foreach (GridColumn column in grid.Columns)
            {
                singleTable.Cells[col, row].Value = item[column.UniqueName].Text;
                col++;
            }
            col = 1;
            row++;
        }

        if (ExportingType.SelectedValue == "1")
        {
            structure.Tables.Add(singleTable);            
        }
    }
    private void GenerateTable(RadGrid grid, xls.Table singleTable)
    {
        if (ExportingType.SelectedValue == "1")
        {
            singleTable       = new xls.Table(grid.ID);
            singleTable.Title = grid.ID;
            row = 2;
            col = 1;
        }
        else
        {
            if (!isFirstItem)
            {
                row++;
            }
            else
            {
                row = 2;
            }
            isFirstItem = false;
        }

        GridHeaderItem headerItem = grid.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem;

        int[] sizearr = new int[15];
        for (int i = 2; i < headerItem.Cells.Count; i++)
        {
            //singleTable.InsertImage(new Range("A1", "B2"), "../Images/Company_Logo/ADNOC.png");

            singleTable.Cells[2, row - 1].Value           = grid.ID;
            singleTable.Cells[2, row - 1].Style.ForeColor = System.Drawing.Color.GreenYellow;
            singleTable.Cells[2, row - 1].Style.Font.Size = 18;
            singleTable.Cells[2, row - 1].Style.Font.Bold = true;
            singleTable.Rows[row - 1].Height = 30;
            singleTable.Cells[3, 1].Value    = " Date : " + DateTime.Now.ToString("dddd, dd MMMM yyyy h:mm tt");
            singleTable.Cells[3, row - 1].Style.ForeColor = System.Drawing.Color.Red;

            singleTable.Rows[row].Height                          = 25;
            singleTable.Cells[i - 1, row].Value                   = headerItem.Cells[i].Text.Replace("_", " ");
            singleTable.Cells[i - 1, row].Style.BackColor         = System.Drawing.Color.LightGray;
            singleTable.Cells[i - 1, row].Style.Font.Bold         = true;
            singleTable.Cells[i - 1, row].Style.Font.Size         = 10;
            singleTable.Cells[i - 1, row].Style.BorderLeftStyle   = BorderStyle.Outset;
            singleTable.Cells[i - 1, row].Style.BorderRightStyle  = BorderStyle.Outset;
            singleTable.Cells[i - 1, row].Style.BorderBottomStyle = BorderStyle.Outset;
            singleTable.Cells[i - 1, row].Style.BorderTopStyle    = BorderStyle.Outset;
            singleTable.Cells[i - 1, row].Style.BorderRightColor  = System.Drawing.Color.Black;
            singleTable.Cells[i - 1, row].Style.BorderTopColor    = System.Drawing.Color.Black;
            singleTable.Cells[i - 1, row].Style.BorderLeftColor   = System.Drawing.Color.Black;
            singleTable.Cells[i - 1, row].Style.BorderBottomColor = System.Drawing.Color.Black;
        }

        row++;

        foreach (GridDataItem item in grid.MasterTableView.Items)
        {
            foreach (GridColumn column in grid.MasterTableView.AutoGeneratedColumns)
            {
                singleTable.Cells[col, row].Value = item[column.UniqueName].Text.Replace("&nbsp;", "");
                singleTable.Cells[col, row].Style.BorderLeftStyle   = BorderStyle.Outset;
                singleTable.Cells[col, row].Style.BorderRightStyle  = BorderStyle.Outset;
                singleTable.Cells[col, row].Style.BorderBottomStyle = BorderStyle.Outset;
                singleTable.Cells[col, row].Style.BorderTopStyle    = BorderStyle.Outset;
                singleTable.Cells[col, row].Style.BorderRightColor  = System.Drawing.Color.Black;
                singleTable.Cells[col, row].Style.BorderTopColor    = System.Drawing.Color.Black;
                singleTable.Cells[col, row].Style.BorderLeftColor   = System.Drawing.Color.Black;
                singleTable.Cells[col, row].Style.BorderBottomColor = System.Drawing.Color.Black;
                col++;
            }
            col = 1;
            row++;
        }

        GridFooterItem FooterItem = grid.MasterTableView.GetItems(GridItemType.Footer)[0] as GridFooterItem;

        for (int i = 2; i < FooterItem.Cells.Count; i++)
        {
            singleTable.Rows[row].Height                          = 25;
            singleTable.Cells[i - 1, row].Value                   = FooterItem.Cells[i].Text.Replace("_", " ").Replace("&nbsp;", "");
            singleTable.Cells[i - 1, row].Style.BackColor         = System.Drawing.Color.LightBlue;
            singleTable.Cells[i - 1, row].Style.Font.Bold         = true;
            singleTable.Cells[i - 1, row].Style.Font.Size         = 10;
            singleTable.Cells[i - 1, row].Style.BorderLeftStyle   = BorderStyle.Outset;
            singleTable.Cells[i - 1, row].Style.BorderRightStyle  = BorderStyle.Outset;
            singleTable.Cells[i - 1, row].Style.BorderBottomStyle = BorderStyle.Outset;
            singleTable.Cells[i - 1, row].Style.BorderTopStyle    = BorderStyle.Outset;
            singleTable.Cells[i - 1, row].Style.BorderRightColor  = System.Drawing.Color.Black;
            singleTable.Cells[i - 1, row].Style.BorderTopColor    = System.Drawing.Color.Black;
            singleTable.Cells[i - 1, row].Style.BorderLeftColor   = System.Drawing.Color.Black;
            singleTable.Cells[i - 1, row].Style.BorderBottomColor = System.Drawing.Color.Black;
        }
        row++;
        row++;

        if (ExportingType.SelectedValue == "1")
        {
            structure.Tables.Add(singleTable);
        }
    }