2012的。
你要是没有,就在你的版本上随便建个form,把下面代码粘进去应该就行。
using C1.Win.C1FlexGrid;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.flxGrid.LoadExcel("C:/test_data.xlsx", FileFlags.AsDisplayed | FileFlags.IncludeFixedCells | FileFlags.IncludeMergedRanges);
var dic1 = new Dictionary<int, string>();
dic1.Add(0, "a");
dic1.Add(1, "b");
dic1.Add(2, "c");
var dic2 = new Dictionary<int, string>();
dic2.Add(0, "A");
dic2.Add(1, "B");
dic2.Add(2, "C");
for (int row = 2; row < this.flxGrid.Rows.Count; row++)
{
this.flxGrid.GetCellStyle(row, 3).DataMap = dic1;
this.flxGrid.GetCellStyle(row, 8).DataMap = dic2;
}
CellStyle cs;
this.flxGrid.SelectionMode = SelectionModeEnum.Row;
this.flxGrid.HighLight = HighLightEnum.WithFocus;
this.flxGrid.Rows.Fixed = 2;
this.flxGrid.Cols.Frozen = 5;
this.flxGrid.Rows[0].AllowMerging = true;
this.flxGrid.Rows[1].AllowMerging = true;
this.flxGrid.Cols.Count = 10;
this.flxGrid.Cols.Fixed = 0;
cs = this.flxGrid.Styles.SelectedColumnHeader;
cs.Border.Color = Color.FromArgb(53, 56, 56);
cs.BackColor = Color.FromArgb(70, 77, 87);
cs.ForeColor = Color.White;
cs.Font = new Font("Meiryo UI", 12, FontStyle.Regular);
cs.TextAlign = TextAlignEnum.CenterCenter;
for (int row = 0; row < this.flxGrid.Rows.Count; row++)
{
this.flxGrid.Rows[row].Height = 25;
}
}
}
} |