本文介绍如何使用spire.xls for java在excel文档中设置行高和列宽。
import com.spire.xls.*;
public class setwidthandheight {
public static void main(string[] args) {
//创建workbook对象
workbook workbook = new workbook();
//获取第一个工作表
worksheet worksheet = workbook.getworksheets().get(0);
//写入文本
worksheet.getcellrange("a1").settext("行高 = 30");
worksheet.getcellrange("d4").settext("列宽 = 20");
//将第一行的行高设为30
worksheet.setrowheight(1,30);
//将第四列的列宽设为20
worksheet.setcolumnwidth(4, 20);
//保存文档
workbook.savetofile("setwidthandheight.xlsx", excelversion.version2016);
}
}