// Handles the "create invoice" button click event and create an invoice.
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        GridWorksheetCollection sheets = GridWeb1.WorkSheets;

      // Clears all sheets.
      sheets.Clear();

      // Creates a new worksheet named "Invoice".
      GridWorksheet sheet = sheets.Add("Invoice");

      sheet.Cells[0, 0].Value = "Order ID";
      // Sets the font size of the cell.
      sheet.Cells[0, 0].Style.Font.Size = new FontUnit("10pt");
      sheet.Cells[0, 0].Style.Font.Bold = true;
      sheet.Cells[0, 0].Style.ForeColor = Color.Blue;
      sheet.Cells[0, 0].Style.BackColor = Color.Aqua;
      sheet.Cells[0, 0].Style.HorizontalAlign = HorizontalAlign.Center;
      sheet.Cells[0, 0].Style.BorderStyle = BorderStyle.Double;
      sheet.Cells[0, 0].Style.BorderColor = Color.Gold;
      sheet.Cells[0, 0].Style.BorderWidth = 3;

      sheet.Cells[0, 1].Value = "Customer ID";
      // Another way to set the font size.
      sheet.Cells[0, 1].Style.Font.Size = new FontUnit(new Unit(10, UnitType.Point));
      sheet.Cells[0, 1].Style.Font.Bold = true;
      sheet.Cells[0, 1].Style.ForeColor = Color.Blue;
      sheet.Cells[0, 1].Style.BackColor = Color.Aqua;
      sheet.Cells[0, 1].Style.HorizontalAlign = HorizontalAlign.Center;
      sheet.Cells[0, 1].Style.BorderStyle = BorderStyle.Double;
      sheet.Cells[0, 1].Style.BorderColor = Color.Gold;
      sheet.Cells[0, 1].Style.BorderWidth = 3;

      sheet.Cells[0, 2].Value = "Salesperson";
      sheet.Cells[0, 2].Style.Font.Size = new FontUnit("10pt");
      sheet.Cells[0, 2].Style.Font.Bold = true;
      sheet.Cells[0, 2].Style.ForeColor = Color.Blue;
      sheet.Cells[0, 2].Style.BackColor = Color.Aqua;
      sheet.Cells[0, 2].Style.HorizontalAlign = HorizontalAlign.Center;
      sheet.Cells[0, 2].Style.BorderStyle = BorderStyle.Double;
      sheet.Cells[0, 2].Style.BorderColor = Color.Gold;
      sheet.Cells[0, 2].Style.BorderWidth = 3;

      sheet.Cells[0, 3].Value = "Order Date";
      sheet.Cells[0, 3].Style.Font.Size = new FontUnit("10pt");
      sheet.Cells[0, 3].Style.Font.Bold = true;
      sheet.Cells[0, 3].Style.ForeColor = Color.Blue;
      sheet.Cells[0, 3].Style.BackColor = Color.Aqua;
      sheet.Cells[0, 3].Style.HorizontalAlign = HorizontalAlign.Center;
      sheet.Cells[0, 3].Style.BorderStyle = BorderStyle.Double;
      sheet.Cells[0, 3].Style.BorderColor = Color.Gold;
      sheet.Cells[0, 3].Style.BorderWidth = 3;

      sheet.Cells[0, 4].Value = "Ship Via";
      sheet.Cells[0, 4].Style.Font.Size = new FontUnit("10pt");
      sheet.Cells[0, 4].Style.Font.Bold = true;
      sheet.Cells[0, 4].Style.ForeColor = Color.Blue;
      sheet.Cells[0, 4].Style.BackColor = Color.Aqua;
      sheet.Cells[0, 4].Style.HorizontalAlign = HorizontalAlign.Center;
      sheet.Cells[0, 4].Style.BorderStyle = BorderStyle.Double;
      sheet.Cells[0, 4].Style.BorderColor = Color.Gold;
      sheet.Cells[0, 4].Style.BorderWidth = 3;

      sheet.Cells[1, 0].Value = "11077";
      sheet.Cells[1, 0].Style.HorizontalAlign = HorizontalAlign.Right;
      sheet.Cells[1, 1].Value = "RATTC";
      sheet.Cells[1, 1].Style.HorizontalAlign = HorizontalAlign.Center;
      sheet.Cells[1, 2].Value = "Nancy Davolio";
      sheet.Cells[1, 2].Style.HorizontalAlign = HorizontalAlign.Center;
      sheet.Cells[1, 3].PutValue(Convert.ToDateTime("2004-5-10"));
      sheet.Cells[1, 3].Style.HorizontalAlign = HorizontalAlign.Right;
      style = sheet.Cells[1, 3].Style;
      sheet.Cells[1, 3].Style.NumberType = (int)NumberType.Date2;
      
      sheet.Cells[1, 4].Value = "United Package";
      sheet.Cells[1, 4].Style.HorizontalAlign = HorizontalAlign.Center;

      sheet.Cells[2, 0].Value = "11076";
      sheet.Cells[2, 0].Style.HorizontalAlign = HorizontalAlign.Right;
      sheet.Cells[2, 1].Value = "BONAP";
      sheet.Cells[2, 1].Style.HorizontalAlign = HorizontalAlign.Center;
      sheet.Cells[2, 2].Value = "Margaret Peacock";
      sheet.Cells[2, 2].Style.HorizontalAlign = HorizontalAlign.Center;
      sheet.Cells[2, 3].PutValue(Convert.ToDateTime("2004-5-02"));
      sheet.Cells[2, 3].Style.HorizontalAlign = HorizontalAlign.Right;
      style = sheet.Cells[2, 3].Style;
      sheet.Cells[2, 3].Style.NumberType = (int)NumberType.Date2;
      
      sheet.Cells[2, 4].Value = "United Package";
      sheet.Cells[2, 4].Style.HorizontalAlign = HorizontalAlign.Center;

      // Sets the column width.
      sheet.Cells.SetColumnWidth(1, 20);
      sheet.Cells.SetColumnWidth(2, 20);
      sheet.Cells.SetColumnWidth(3, 20);
      sheet.Cells.SetColumnWidth(4, 20);

      //set the row height
      sheet.Cells.SetRowHeight(0, 20);
    }
  private void InitData()
		{
            GridWeb1.WorkSheets.Clear();
            GridWorksheet sheet = GridWeb1.WorkSheets.Add("Students");
            GridCells cells = sheet.Cells;
			cells[0, 0].PutValue("Name");
            GridTableItemStyle cellstyle = cells[0, 0].Style;
            cellstyle.Font.Size = new FontUnit("10pt");
            cellstyle.Font.Bold = true;
            cellstyle.ForeColor = Color.Black;
            cellstyle.HorizontalAlign = HorizontalAlign.Center;
            cellstyle.BorderWidth = 1;
            cells[0, 0].Style = cellstyle;



            cells[1, 0].PutValue("Jack");
            cells[1, 1].PutValue("M");
            cells[1, 2].PutValue(19);
            cells[1, 3].PutValue("One");

            cells[2, 0].PutValue("Tome");
            cells[2, 1].PutValue("M");
            cells[2, 2].PutValue(20);
            cells[2, 3].PutValue("Four");

            cells[3, 0].PutValue("Jeney");
            cells[3, 1].PutValue("W");
            cells[3, 2].PutValue(18);
            cells[3, 3].PutValue("Two");

            cells[4, 0].PutValue("Marry");
            cells[4, 1].PutValue("W");
            cells[4, 2].PutValue(17);
            cells[4, 3].PutValue("There");

            cells[5, 0].PutValue("Amy");
            cells[5, 1].PutValue("W");
            cells[5, 2].PutValue(16);
            cells[5, 3].PutValue("Four");

            cells[6, 0].PutValue("Ben");
            cells[6, 1].PutValue("M");
            cells[6, 2].PutValue(17);
            cells[6, 3].PutValue("Four");

            GridCell cell = cells[0, 1];
            Aspose.Cells.GridWeb.GridTableItemStyle style = cell.Style;
            style.Font.Size = new FontUnit("22pt");
            style.Wrap = false;

            //style.BackColor = Color.Gray;
            

            style.RightBorderStyle.BorderColor = Color.Red;
            style.RightBorderStyle.BorderStyle = BorderStyle.Dotted;
            style.BottomBorderStyle.BorderColor = Color.Green;
            style.BottomBorderStyle.BorderStyle = BorderStyle.Groove;
            style.TopBorderStyle.BorderColor = Color.Yellow;
            style.TopBorderStyle.BorderStyle = BorderStyle.Inset;
            style.LeftBorderStyle.BorderColor = Color.Coral;
            style.LeftBorderStyle.BorderStyle = BorderStyle.Solid;

           
            cells[0, 1].Style = style;
            Aspose.Cells.GridWeb.GridTableItemStyle vtstyle1 = new Aspose.Cells.GridWeb.GridTableItemStyle();
            vtstyle1.CopyFrom(style);
            vtstyle1.LeftBorderStyle.BorderWidth = new Unit(1, UnitType.Pixel);
            vtstyle1.TopBorderStyle.BorderWidth = new Unit(1, UnitType.Pixel);

          //  cells[0, 0].SetStyle(vtstyle1);
         //   cells[1, 2].SetStyle(style);

            Aspose.Cells.GridWeb.GridTableItemStyle vtstyle2 = new Aspose.Cells.GridWeb.GridTableItemStyle();
            vtstyle2.CopyFrom(style);
            vtstyle2.LeftBorderStyle.BorderWidth = new Unit(10, UnitType.Pixel);
           // style.LeftBorderStyle.BorderWidth = new Unit(50, UnitType.Pixel);
          //  cells[3, 0].SetStyle(vtstyle2);

            Aspose.Cells.GridWeb.GridTableItemStyle vtstyle3 = new Aspose.Cells.GridWeb.GridTableItemStyle();
            vtstyle3.CopyFrom(style);
            vtstyle3.TopBorderStyle.BorderWidth = new Unit(1, UnitType.Pixel);
            vtstyle3.BottomBorderStyle.BorderWidth = new Unit(80, UnitType.Pixel);
          //  cells[0, 1].SetStyle(vtstyle3);

            Aspose.Cells.GridWeb.GridTableItemStyle vtstyle4 = new Aspose.Cells.GridWeb.GridTableItemStyle();
            vtstyle4.CopyFrom(vtstyle3);
            vtstyle4.TopBorderStyle.BorderWidth = new Unit(1, UnitType.Pixel);
            vtstyle4.BottomBorderStyle.BorderWidth = new Unit(50, UnitType.Pixel);
           // cells[0, 2].SetStyle(vtstyle4);


            Aspose.Cells.GridWeb.GridTableItemStyle vtstyle5 = new Aspose.Cells.GridWeb.GridTableItemStyle();
            vtstyle5.CopyFrom(vtstyle3);
            vtstyle5.TopBorderStyle.BorderWidth = new Unit(1, UnitType.Pixel);
            vtstyle5.BottomBorderStyle.BorderWidth = new Unit(150, UnitType.Pixel);

            vtstyle5.RightBorderStyle.BorderWidth = new Unit(40, UnitType.Pixel);
            vtstyle5.LeftBorderStyle.BorderWidth = new Unit(20, UnitType.Pixel);

          //  cells[1, 1].SetStyle(vtstyle5);

            Aspose.Cells.GridWeb.GridTableItemStyle vtstyle = new Aspose.Cells.GridWeb.GridTableItemStyle();
            vtstyle.CopyFrom(style);
            vtstyle.RightBorderStyle.BorderWidth = new Unit(50, UnitType.Pixel);
          //  cells[1, 4].SetStyle(vtstyle);
     // cells[1, 4]
           // WebCell cellheader = sheet.
          //  cellheader.SetStyle(style);
           // GridWeb1.SetHeaderBarStyle(new HeaderBarStyle() );

            cells.SetRowHeight(0, 20);
            cells.SetRowHeight(1, 20);

				
			cells.SetColumnWidth(0, 10);
			cells.SetColumnWidth(1, 10);
			cells.SetColumnWidth(2, 10);
			cells.SetColumnWidth(3, 10);
		}
        // Handles the "create invoice" button click event and create an invoice.
        protected void Button1_Click(object sender, System.EventArgs e)
        {
            GridWorksheetCollection sheets = GridWeb1.WorkSheets;

            // Clears all sheets.
            sheets.Clear();

            // Creates a new worksheet named "Invoice".
            GridWorksheet sheet = sheets.Add("Invoice");

            sheet.Cells[0, 0].Value = "Order ID";
            // Sets the font size of the cell.
            sheet.Cells[0, 0].Style.Font.Size       = new FontUnit("10pt");
            sheet.Cells[0, 0].Style.Font.Bold       = true;
            sheet.Cells[0, 0].Style.ForeColor       = Color.Blue;
            sheet.Cells[0, 0].Style.BackColor       = Color.Aqua;
            sheet.Cells[0, 0].Style.HorizontalAlign = HorizontalAlign.Center;
            sheet.Cells[0, 0].Style.BorderStyle     = BorderStyle.Double;
            sheet.Cells[0, 0].Style.BorderColor     = Color.Gold;
            sheet.Cells[0, 0].Style.BorderWidth     = 3;

            sheet.Cells[0, 1].Value = "Customer ID";
            // Another way to set the font size.
            sheet.Cells[0, 1].Style.Font.Size       = new FontUnit(new Unit(10, UnitType.Point));
            sheet.Cells[0, 1].Style.Font.Bold       = true;
            sheet.Cells[0, 1].Style.ForeColor       = Color.Blue;
            sheet.Cells[0, 1].Style.BackColor       = Color.Aqua;
            sheet.Cells[0, 1].Style.HorizontalAlign = HorizontalAlign.Center;
            sheet.Cells[0, 1].Style.BorderStyle     = BorderStyle.Double;
            sheet.Cells[0, 1].Style.BorderColor     = Color.Gold;
            sheet.Cells[0, 1].Style.BorderWidth     = 3;

            sheet.Cells[0, 2].Value                 = "Salesperson";
            sheet.Cells[0, 2].Style.Font.Size       = new FontUnit("10pt");
            sheet.Cells[0, 2].Style.Font.Bold       = true;
            sheet.Cells[0, 2].Style.ForeColor       = Color.Blue;
            sheet.Cells[0, 2].Style.BackColor       = Color.Aqua;
            sheet.Cells[0, 2].Style.HorizontalAlign = HorizontalAlign.Center;
            sheet.Cells[0, 2].Style.BorderStyle     = BorderStyle.Double;
            sheet.Cells[0, 2].Style.BorderColor     = Color.Gold;
            sheet.Cells[0, 2].Style.BorderWidth     = 3;

            sheet.Cells[0, 3].Value                 = "Order Date";
            sheet.Cells[0, 3].Style.Font.Size       = new FontUnit("10pt");
            sheet.Cells[0, 3].Style.Font.Bold       = true;
            sheet.Cells[0, 3].Style.ForeColor       = Color.Blue;
            sheet.Cells[0, 3].Style.BackColor       = Color.Aqua;
            sheet.Cells[0, 3].Style.HorizontalAlign = HorizontalAlign.Center;
            sheet.Cells[0, 3].Style.BorderStyle     = BorderStyle.Double;
            sheet.Cells[0, 3].Style.BorderColor     = Color.Gold;
            sheet.Cells[0, 3].Style.BorderWidth     = 3;

            sheet.Cells[0, 4].Value                 = "Ship Via";
            sheet.Cells[0, 4].Style.Font.Size       = new FontUnit("10pt");
            sheet.Cells[0, 4].Style.Font.Bold       = true;
            sheet.Cells[0, 4].Style.ForeColor       = Color.Blue;
            sheet.Cells[0, 4].Style.BackColor       = Color.Aqua;
            sheet.Cells[0, 4].Style.HorizontalAlign = HorizontalAlign.Center;
            sheet.Cells[0, 4].Style.BorderStyle     = BorderStyle.Double;
            sheet.Cells[0, 4].Style.BorderColor     = Color.Gold;
            sheet.Cells[0, 4].Style.BorderWidth     = 3;

            sheet.Cells[1, 0].Value = "11077";
            sheet.Cells[1, 0].Style.HorizontalAlign = HorizontalAlign.Right;
            sheet.Cells[1, 1].Value = "RATTC";
            sheet.Cells[1, 1].Style.HorizontalAlign = HorizontalAlign.Center;
            sheet.Cells[1, 2].Value = "Nancy Davolio";
            sheet.Cells[1, 2].Style.HorizontalAlign = HorizontalAlign.Center;
            sheet.Cells[1, 3].PutValue(Convert.ToDateTime("2004-5-10"));
            sheet.Cells[1, 3].Style.HorizontalAlign = HorizontalAlign.Right;
            style = sheet.Cells[1, 3].Style;
            sheet.Cells[1, 3].Style.NumberType = (int)NumberType.Date2;

            sheet.Cells[1, 4].Value = "United Package";
            sheet.Cells[1, 4].Style.HorizontalAlign = HorizontalAlign.Center;

            sheet.Cells[2, 0].Value = "11076";
            sheet.Cells[2, 0].Style.HorizontalAlign = HorizontalAlign.Right;
            sheet.Cells[2, 1].Value = "BONAP";
            sheet.Cells[2, 1].Style.HorizontalAlign = HorizontalAlign.Center;
            sheet.Cells[2, 2].Value = "Margaret Peacock";
            sheet.Cells[2, 2].Style.HorizontalAlign = HorizontalAlign.Center;
            sheet.Cells[2, 3].PutValue(Convert.ToDateTime("2004-5-02"));
            sheet.Cells[2, 3].Style.HorizontalAlign = HorizontalAlign.Right;
            style = sheet.Cells[2, 3].Style;
            sheet.Cells[2, 3].Style.NumberType = (int)NumberType.Date2;

            sheet.Cells[2, 4].Value = "United Package";
            sheet.Cells[2, 4].Style.HorizontalAlign = HorizontalAlign.Center;

            // Sets the column width.
            sheet.Cells.SetColumnWidth(1, 20);
            sheet.Cells.SetColumnWidth(2, 20);
            sheet.Cells.SetColumnWidth(3, 20);
            sheet.Cells.SetColumnWidth(4, 20);

            // Set the row height
            sheet.Cells.SetRowHeight(0, 20);
        }
Exemple #4
0
    private void InitData()
    {
        GridWeb1.WorkSheets.Clear();
        GridWorksheet sheet = GridWeb1.WorkSheets.Add("Students");
        GridCells     cells = sheet.Cells;

        cells[0, 0].PutValue("Name");
        GridTableItemStyle cellstyle = cells[0, 0].Style;

        cellstyle.Font.Size       = new FontUnit("10pt");
        cellstyle.Font.Bold       = true;
        cellstyle.ForeColor       = Color.Black;
        cellstyle.HorizontalAlign = HorizontalAlign.Center;
        cellstyle.BorderWidth     = 1;
        cells[0, 0].Style         = cellstyle;



        cells[1, 0].PutValue("Jack");
        cells[1, 1].PutValue("M");
        cells[1, 2].PutValue(19);
        cells[1, 3].PutValue("One");

        cells[2, 0].PutValue("Tome");
        cells[2, 1].PutValue("M");
        cells[2, 2].PutValue(20);
        cells[2, 3].PutValue("Four");

        cells[3, 0].PutValue("Jeney");
        cells[3, 1].PutValue("W");
        cells[3, 2].PutValue(18);
        cells[3, 3].PutValue("Two");

        cells[4, 0].PutValue("Marry");
        cells[4, 1].PutValue("W");
        cells[4, 2].PutValue(17);
        cells[4, 3].PutValue("There");

        cells[5, 0].PutValue("Amy");
        cells[5, 1].PutValue("W");
        cells[5, 2].PutValue(16);
        cells[5, 3].PutValue("Four");

        cells[6, 0].PutValue("Ben");
        cells[6, 1].PutValue("M");
        cells[6, 2].PutValue(17);
        cells[6, 3].PutValue("Four");

        GridCell cell = cells[0, 1];

        Aspose.Cells.GridWeb.GridTableItemStyle style = cell.Style;
        style.Font.Size = new FontUnit("22pt");
        style.Wrap      = false;

        //style.BackColor = Color.Gray;


        style.RightBorderStyle.BorderColor  = Color.Red;
        style.RightBorderStyle.BorderStyle  = BorderStyle.Dotted;
        style.BottomBorderStyle.BorderColor = Color.Green;
        style.BottomBorderStyle.BorderStyle = BorderStyle.Groove;
        style.TopBorderStyle.BorderColor    = Color.Yellow;
        style.TopBorderStyle.BorderStyle    = BorderStyle.Inset;
        style.LeftBorderStyle.BorderColor   = Color.Coral;
        style.LeftBorderStyle.BorderStyle   = BorderStyle.Solid;


        cells[0, 1].Style = style;
        Aspose.Cells.GridWeb.GridTableItemStyle vtstyle1 = new Aspose.Cells.GridWeb.GridTableItemStyle();
        vtstyle1.CopyFrom(style);
        vtstyle1.LeftBorderStyle.BorderWidth = new Unit(1, UnitType.Pixel);
        vtstyle1.TopBorderStyle.BorderWidth  = new Unit(1, UnitType.Pixel);

        //  cells[0, 0].SetStyle(vtstyle1);
        //   cells[1, 2].SetStyle(style);

        Aspose.Cells.GridWeb.GridTableItemStyle vtstyle2 = new Aspose.Cells.GridWeb.GridTableItemStyle();
        vtstyle2.CopyFrom(style);
        vtstyle2.LeftBorderStyle.BorderWidth = new Unit(10, UnitType.Pixel);
        // style.LeftBorderStyle.BorderWidth = new Unit(50, UnitType.Pixel);
        //  cells[3, 0].SetStyle(vtstyle2);

        Aspose.Cells.GridWeb.GridTableItemStyle vtstyle3 = new Aspose.Cells.GridWeb.GridTableItemStyle();
        vtstyle3.CopyFrom(style);
        vtstyle3.TopBorderStyle.BorderWidth    = new Unit(1, UnitType.Pixel);
        vtstyle3.BottomBorderStyle.BorderWidth = new Unit(80, UnitType.Pixel);
        //  cells[0, 1].SetStyle(vtstyle3);

        Aspose.Cells.GridWeb.GridTableItemStyle vtstyle4 = new Aspose.Cells.GridWeb.GridTableItemStyle();
        vtstyle4.CopyFrom(vtstyle3);
        vtstyle4.TopBorderStyle.BorderWidth    = new Unit(1, UnitType.Pixel);
        vtstyle4.BottomBorderStyle.BorderWidth = new Unit(50, UnitType.Pixel);
        // cells[0, 2].SetStyle(vtstyle4);


        Aspose.Cells.GridWeb.GridTableItemStyle vtstyle5 = new Aspose.Cells.GridWeb.GridTableItemStyle();
        vtstyle5.CopyFrom(vtstyle3);
        vtstyle5.TopBorderStyle.BorderWidth    = new Unit(1, UnitType.Pixel);
        vtstyle5.BottomBorderStyle.BorderWidth = new Unit(150, UnitType.Pixel);

        vtstyle5.RightBorderStyle.BorderWidth = new Unit(40, UnitType.Pixel);
        vtstyle5.LeftBorderStyle.BorderWidth  = new Unit(20, UnitType.Pixel);

        //  cells[1, 1].SetStyle(vtstyle5);

        Aspose.Cells.GridWeb.GridTableItemStyle vtstyle = new Aspose.Cells.GridWeb.GridTableItemStyle();
        vtstyle.CopyFrom(style);
        vtstyle.RightBorderStyle.BorderWidth = new Unit(50, UnitType.Pixel);
        //  cells[1, 4].SetStyle(vtstyle);
        // cells[1, 4]
        // WebCell cellheader = sheet.
        //  cellheader.SetStyle(style);
        // GridWeb1.SetHeaderBarStyle(new HeaderBarStyle() );

        cells.SetRowHeight(0, 20);
        cells.SetRowHeight(1, 20);


        cells.SetColumnWidth(0, 10);
        cells.SetColumnWidth(1, 10);
        cells.SetColumnWidth(2, 10);
        cells.SetColumnWidth(3, 10);
    }