Aspose.Cells 使用汇总
来源:互联网 发布:网络销售犯罪的特征有 编辑:程序博客网 时间:2024/05/27 20:10
/新建工作簿Workbook workbook = new Workbook(); //工作簿Worksheet sheet = workbook.Worksheets[0]; //工作表Cells cells = sheet.Cells;//单元格 sheet.Protect(ProtectionType.All, "123123", "");//保护工作表sheet.Protection.IsSelectingLockedCellsAllowed = false;//设置只能选择解锁单元格sheet.Protection.IsFormattingColumnsAllowed = true;//设置可以调整列sheet.Protection.IsFormattingRowsAllowed = true;//设置可以调整行 Style style1 = workbook.Styles[workbook.Styles.Add()];//新增样式style1.HorizontalAlignment = TextAlignmentType.Center;//文字居中style1.Font.Name = "宋体";//文字字体style1.Font.Size = 22;//文字大小style1.IsLocked = false;//单元格解锁style1.Font.IsBold = true;//粗体style1.ForegroundColor = Color.FromArgb(0xaa, 0xcc, 0xbb);//设置背景色style1.Pattern = BackgroundType.Solid; //设置背景样式style1.IsTextWrapped = true;//单元格内容自动换行style1.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin; //应用边界线 左边界线style1.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin; //应用边界线 右边界线style1.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin; //应用边界线 上边界线style1.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin; //应用边界线 下边界线
cells.Merge(0, 0, 1, 5);//合并单元格cells[0, 0].PutValue("内容");//填写内容cells[0, 0].SetStyle(style1);//给单元格关联样式 cells.SetRowHeight(0, 20);//设置行高cells.SetColumnWidth(1, 30);//设置列宽cells[1, 0].Formula = "=AVERAGE(B1:E1)";//给单元格设置计算公式
//从Cells[0,0]开始创建一个2行3列的RangeRange range = ws.Cells.CreateRange(0, 0, 2, 3);Cell cell = range[0, 0];cell.Style.Font = 9;range.Style = style;range.Merge();
注意Range不能直接设置Style.必须先定义style再将style赋给Style.其他设置和Cell基本一致.Range的Style会覆盖Cell定义的Style.另外必须先赋值再传Style.否则可能不生效.
</pre><pre code_snippet_id="1630545" snippet_file_name="blog_20160331_3_2386885" name="code" class="csharp" style="margin-top: 0px; margin-bottom: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; line-height: 18px; background-color: rgb(245, 250, 254);">使用Formula:sheet.Cells[0,0].PutValue(1);sheet.Cells[1,0].PutValue(20);sheet.Cells[2,0].Formula="SUM(A1:B1)";sheet.CalculateFormula(true);Save Excel文件的时候必须调用CalculateFormula方法计算结果.
0 0
- Aspose.Cells 使用汇总
- Aspose.Cells 使用整理
- aspose.cells基础使用
- itextsharp、Aspose.Words、Aspose.Cells联合使用
- Aspose.Cells使用教程大全
- 使用Aspose.Cells生成Excel
- Aspose.Cells
- 使用Aspose.Cells的基础知识整理
- [转]使用Aspose.Cells的基础知识整理
- 使用Aspose.Cells的基础知识整理
- 使用Aspose.Cells的基础知识整理[转]
- 使用Aspose.Cells的基础知识整理 .
- 使用Aspose.Cells的基础知识整理
- aspose.cells使用excel模板生成excel
- 使用 Aspose.Cells单元格生成超链接 URL
- Aspose.Cells教学视频
- Aspose.Cells简单用法
- Aspose.Cells中文版文档
- linuxrw
- 亲爱的程序猿们怎么找工作
- SQLServer2008 表连接时null 和 null 无法匹配?
- SQLServer2008 关于while循环
- 第5周项目1-(2)
- Aspose.Cells 使用汇总
- [转]IOS开源项目组件
- JAVA多线程和并发基础面试问答
- [转]接口和抽象类
- Windows7添加路径到path环境变量
- Java中Ajaxa中文乱码问题
- 项目2——游戏中的角色类
- 数据库设计
- JNI/NDK开发指南(三)——JNI数据类型及与Java数据类型的映射关系