Aspose.Cells控件
- 基本操作
- Aspose.Cells 基础用法 转自(https://www.cnblogs.com/codealone/p/3365342.html)
基本操作
Aspose.Cells 基础用法 转自(https://www.cnblogs.com/codealone/p/3365342.html)
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
sheet.Name = "表1";
Cells cells = sheet.Cells;
cells[0, 0].PutValue("用户名");
cells[0, 1].PutValue("密码");
cells[1, 0].PutValue("admin");
cells[1, 1].PutValue("admin");
cells[2, 0].PutValue("test");
cells[2, 1].PutValue("test");
sheet.Hyperlinks.Add(0, 0, 1, 1, "http://www.baidu.com");
sheet.Hyperlinks.Add(0, 1, 1, 1, "表1!A20");
Style style = workbook.Styles[workbook.Styles.Add()];
style.HorizontalAlignment = Aspose.Cells.TextAlignmentType.Center;
style.ForegroundColor = Color.Green;
style.Pattern = BackgroundType.Solid;
cells[2, 0].SetStyle(style);
var comIndex = sheet.Comments.Add(3, 3);
sheet.Comments[comIndex].Note = "这里是批注";
workbook.Save(@".\结果.xlsx");