回复 3楼dlz5788的帖子
排序结果和该列的数据类型有关,如果是数值型排序结果是1,2,3,12,21,22,32;如果字符串结果就是1,12,2,21,22,3,32
- private void Form2_Load(object sender, EventArgs e)
- {
- fpSpread1.ActiveSheet.Cells[0, 0].Value = 1;
- fpSpread1.ActiveSheet.Cells[1, 0].Value = 12;
- fpSpread1.ActiveSheet.Cells[2, 0].Value = 2;
- fpSpread1.ActiveSheet.Cells[3, 0].Value = 21;
- fpSpread1.ActiveSheet.Cells[4, 0].Value = 22;
- fpSpread1.ActiveSheet.Cells[5, 0].Value = 3;
- fpSpread1.ActiveSheet.Cells[6, 0].Value = 32;
- this.fpSpread1.ActiveSheet.Columns[0].AllowAutoSort = true;
- fpSpread1.ActiveSheet.Cells[0, 1].Value = "1";
- fpSpread1.ActiveSheet.Cells[1, 1].Value = "12";
- fpSpread1.ActiveSheet.Cells[2, 1].Value = "2";
- fpSpread1.ActiveSheet.Cells[3, 1].Value = "21";
- fpSpread1.ActiveSheet.Cells[4, 1].Value = "22";
- fpSpread1.ActiveSheet.Cells[5, 1].Value = "3";
- fpSpread1.ActiveSheet.Cells[6, 1].Value = "32";
- this.fpSpread1.ActiveSheet.Columns[0].AllowAutoSort = true;
- this.fpSpread1.ActiveSheet.Columns[1].AllowAutoSort = true;
- }
复制代码 |