单元格高度宽度几种设置

Excel表格操作技巧
本文介绍了如何使用Java API操作Excel表格,包括设置单元格的高度和宽度、自动调整列宽等实用技巧,有助于提高处理大量数据时的工作效率。
//高度设置
sheet1.CreateRow(0).Height = 200*20;//高度200

//列宽设置1
 int columnWidth = paymentSheet.GetColumnWidth(columnindx) / 256;

 ICell currentCell = currentRow.GetCell(columnindx);
 int length = Encoding.Default.GetBytes(currentCell.ToString()).Length;
            if (columnWidth < length)
            {
              columnWidth = length;
            }

 paymentSheet.SetColumnWidth(columnindx, columnWidth * 256);

//列宽自动识别 ,数据量大的情况运行缓慢
  Sheet sheet=hssfworkbook.CreateSheet("Sheet1");
            Row row=sheet.CreateRow(0);
            row.CreateCell(0).SetCellValue("This is a test");
            row.CreateCell(1).SetCellValue("Hello");
            row.CreateCell(2).SetCellValue("1234.0023");
            row.CreateCell(3).SetCellValue("这是一个测试这是一个测试这是一个测试");
            sheet.AutoSizeColumn(0);
            sheet.AutoSizeColumn(1);
            sheet.AutoSizeColumn(2);
            sheet.AutoSizeColumn(3);
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值