附件是xls文件。
- C1XLBook book = new C1XLBook();
- book.Load(Path.Combine(Application.StartupPath, "tmp.xls"));
- XLSheet sheet = book.Sheets[0];
- Color clr1 = Color.FromArgb(200, 200, 200);
- Color clr2 = Color.FromArgb(240, 240, 240);
- XLCell cell = sheet.GetCell(0, 0);
- XLCell cell2 = sheet.GetCell(1, 0);
- cell = sheet[0, 1];
- cell2 = sheet[1, 1];
- XLStyle stl = new XLStyle(book);
- stl.BackColor = clr1;
- cell.SetValue(200, stl);
- stl = new XLStyle(book);
- stl.BackColor = clr2;
- cell2.SetValue(240, stl);
- book.Palette = new Color[] { clr1, clr2};
-
- book.Save(Path.Combine(Application.StartupPath, "test.xls"));
复制代码
|