Aspose.Cells.GridWeb.Examples.CSharp.Worksheets.SortData.InitData C# (CSharp) Метод

InitData() приватный Метод

private InitData ( ) : void
Результат void
        private void InitData()
        {
            // Gets the web application's path.
            string path = (this.Master as Site).GetDataDir();

            string fileName = path + "\\Worksheets\\Sort.xls";

            // Imports from an excel file.
            GridWeb1.ImportExcelFile(fileName);

            // Creates sorting header style.
            GridTableItemStyle itemStyle = new GridTableItemStyle();
            itemStyle.BorderStyle = BorderStyle.Outset;
            itemStyle.BorderWidth = 2;
            itemStyle.BorderColor = Color.White;
            itemStyle.BackColor = Color.Silver;
            itemStyle.HorizontalAlign = HorizontalAlign.Center;
            itemStyle.VerticalAlign = VerticalAlign.Middle;

            // Creates Hyperlinks Sheet1. Sorts from top to bottom orientation.
            GridHyperlink cellcmd;
            GridCells cells0 = GridWeb1.WorkSheets[0].Cells;
            cells0["A1"].CopyStyle(itemStyle);
            GridHyperlinkCollection ghc = GridWeb1.WorkSheets[0].Hyperlinks;
            int i = ghc.Add("A1", "");
            cellcmd = ghc[i];
            cellcmd.Command = "A1";
            cellcmd.ScreenTip = "Sorts Descending";
            cellcmd.TextToDisplay = "OrderId";

            cells0["B1"].CopyStyle(itemStyle);
            cellcmd = ghc[ghc.Add("B1", "")];
            cellcmd.Command = "B1";
            cellcmd.ScreenTip = "Sorts Ascending";
            cellcmd.TextToDisplay = "Sales Amout";

            cells0["C1"].CopyStyle(itemStyle);
            cellcmd = ghc[ghc.Add("C1", "")];
            cellcmd.Command = "C1";
            cellcmd.ScreenTip = "Sorts Descending";
            cellcmd.TextToDisplay = "Percent of Saler's Total";

            cells0["D1"].CopyStyle(itemStyle);
            cellcmd = ghc[ghc.Add("D1", "")];

            cellcmd.Command = "D1";
            cellcmd.ScreenTip = "Sorts Ascending";
            cellcmd.TextToDisplay = "Percent of Country Total";

            // Creates Hyperlinks Sheet2. Sorts from left to right orientation.
            GridCells cells1 = GridWeb1.WorkSheets[1].Cells;
            GridHyperlinkCollection ghcb = GridWeb1.WorkSheets[1].Hyperlinks;
            cells1["A1"].CopyStyle(itemStyle);
            cellcmd = ghcb[ghcb.Add("A1", "")];

            cellcmd.Command = "1A1";
            cellcmd.ScreenTip = "Sorts Ascending";
            cellcmd.TextToDisplay = "Product";

            cells1["A2"].CopyStyle(itemStyle);
            cellcmd = ghcb[ghcb.Add("A2", "")];

            cellcmd.Command = "1A2";
            cellcmd.ScreenTip = "Sorts Ascending";
            cellcmd.TextToDisplay = "Category";

            cells1["A3"].CopyStyle(itemStyle);
            cellcmd = ghcb[ghcb.Add("A3", "")];

            cellcmd.Command = "1A3";
            cellcmd.ScreenTip = "Sorts Ascending";
            cellcmd.TextToDisplay = "Package";

            cells1["A4"].CopyStyle(itemStyle);
            cellcmd = ghcb[ghcb.Add("A4", "")];

            cellcmd.Command = "1A4";
            cellcmd.ScreenTip = "Sorts Ascending";
            cellcmd.TextToDisplay = "Quantity";
        }