对工作表数据进行排序

排序数据

Aspose.Cells.GridWeb允许开发人员水平和垂直排序数据,以便开发人员可以从上到下或从左到右排序数据。

从上到下

要从上到下方向排序数据:

  1. 将Aspose.Cells.GridWeb控件添加到您的Web表单中。
  2. 访问您要排序的工作表。
  3. 以任意顺序(升序或降序)对数据范围进行排序。确保选择从上到下的方向。

下面的示例以降序方式对工作表的四列数据进行排序。仅对四列的二十行数据按从上到下的方向进行排序。

应用代码之前,工作表包含无序数据。

todo:image_alt_text

执行代码后,数据按升序排序。

todo:image_alt_text

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Sorts Column 1 from top to bottom in descending order
// Cells.Sort(int startRow, int startColumn, int rows, int columns, int index, bool isAsending, bool isCaseSensitive, bool islefttoright);
GridWeb1.WorkSheets[0].Cells.Sort(1, 0, 20, 4, 0, false, true, false);

从左到右

要从左到右排序数据:

  1. 将Aspose.Cells.GridWeb控件添加到您的Web表单中。
  2. 访问您要排序的工作表。
  3. 以任意顺序(升序或降序)对数据范围进行排序。确保选择从左到右的方向。

下面的示例以升序方式对四行数据进行排序。仅对七列的四行数据按从左到右的方向进行排序。

应用代码之前,工作表包含无序数据。

todo:image_alt_text

执行代码后,数据按升序排序。

todo:image_alt_text

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Sorts Row 1 from left to right in ascending order
// Cells.Sort(int startRow, int startColumn, int rows, int columns, int index, bool isAsending, bool isCaseSensitive, bool islefttoright);
GridWeb1.WorkSheets[1].Cells.Sort(0, 1, 4, 7, 0, true, true, true);