如题,希望将c1flexgrid中的数据通过C1.WPF.Excel导出为excel,由于要设置表格的边框,需要选定一个范围进行设置,但这个范围不知道如何设置,我现在的代码是这样的:
C1XLBook book = new C1XLBook();
book.Load(templateFileName); //取得模板文件
XLSheet sheet = book.Sheets[0];
//向excel中写入数据
。。。
//对选定的范围进行格式设置
XLStyle style2=new XLStyle(book);
style2.SetBorderStyle(XLLineStyleEnum.Thin);// = XLLineStyleEnum.Medium;
style2.BorderBottom = XLLineStyleEnum.Thin;
style2.BorderLeft = XLLineStyleEnum.Thin;
style2.BorderRight = XLLineStyleEnum.Thin;
style2.BorderTop = XLLineStyleEnum.Thin;
style2.BorderColorBottom = Color.FromRgb(255, 255, 255);
style2.BorderColorLeft = Color.FromRgb(255, 255, 255);
style2.BorderColorRight = Color.FromRgb(255, 255, 255);
style2.BorderColorTop = Color.FromRgb(255, 255, 255);
XLCellRange range;
range = new C1.WPF.Excel.XLCellRange(8, 13, 8, 13);
sheet.SelectedCells.Add(range);
range.Style = style2;
运行结果excel文件中并没有对相应范围进行格式设置(sheet.SelectedCells.Add(range)这句话的作用仅仅是打开excel文件时选中这个区域),请教如何要实现我需要的结果(这个区域画上边框)应该怎么做呢? |
|