aspose.cell 设置样式 java_C# Aspose.Cells 如何设置单元格样式

这篇博客介绍了如何在Java和C#中使用Aspose.Cells库来设置Excel单元格的样式,包括日期、百分比和货币格式。通过创建Workbook对象,添加工作表,然后设置单元格的值和样式,可以实现自定义显示格式。最后,保存文件到指定路径。
摘要由CSDN通过智能技术生成

//Instantiating a Workbook object

Workbook workbook = newWorkbook();//Adding a new worksheet to the Workbook object

int i =workbook.Worksheets.Add();//Obtaining the reference of the newly added worksheet by passing its sheet index

Worksheet worksheet =workbook.Worksheets[i];//Adding the current system date to "A1" cell

worksheet.Cells["A1"].PutValue(DateTime.Now);//Getting the Style of the A1 Cell

Style style = worksheet.Cells["A1"].GetStyle();//Setting the display format to number 15 to show date as "d-mmm-yy"

style.Number = 15;//Applying the style to the A1 cell

worksheet.Cells["A1"].SetStyle(style);//Adding a numeric value to "A2" cell

worksheet.Cells["A2"].PutValue(20);//Getting the Style of the A2 Cell

style = worksheet.Cells["A2"].GetStyle();//Setting the display format to number

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值