1、错误描述
Exception in thread "main" java.lang.IllegalArgumentException: The ‘to‘ row (0) must not be less than the ‘from‘ row (1) at org.apache.poi.hssf.model.InternalSheet.addMergedRegion(InternalSheet.java:513) at org.apache.poi.hssf.usermodel.HSSFSheet.addMergedRegion(HSSFSheet.java:680) at com.you.excel.ThreeHead.main(ThreeHead.java:130)
2、错误原因
Region region1 = new Region(0, (short)0, 2, (short)0); Region region2 = new Region(0, (short)1, 0, (short)6); Region region3 = new Region(0, (short)7, 0, (short)12); Region region4 = new Region(0, (short)13, 0, (short)18); Region region5 = new Region(1, (short)1, 0, (short)3); Region region6 = new Region(0, (short)4, 0, (short)6); Region region7 = new Region(0, (short)7, 0, (short)9); Region region8 = new Region(0, (short)10, 0, (short)12); Region region9 = new Region(0, (short)13, 0, (short)15); Region region10 = new Region(0, (short)16, 0, (short)18); sheet.addMergedRegion(region1); sheet.addMergedRegion(region2); sheet.addMergedRegion(region3); sheet.addMergedRegion(region4); sheet.addMergedRegion(region5); sheet.addMergedRegion(region6); sheet.addMergedRegion(region7); sheet.addMergedRegion(region8); sheet.addMergedRegion(region9);
Region(int rowFrom, short colFrom, int rowTo, short colTo)
rowFrom要比rowTo小或等于
3、解决办法
Region region1 = new Region(0, (short)0, 2, (short)0); Region region2 = new Region(0, (short)1, 0, (short)6); Region region3 = new Region(0, (short)7, 0, (short)12); Region region4 = new Region(0, (short)13, 0, (short)18); Region region5 = new Region(0, (short)1, 0, (short)3); Region region6 = new Region(0, (short)4, 0, (short)6); Region region7 = new Region(0, (short)7, 0, (short)9); Region region8 = new Region(0, (short)10, 0, (short)12); Region region9 = new Region(0, (short)13, 0, (short)15); Region region10 = new Region(0, (short)16, 0, (short)18); sheet.addMergedRegion(region1); sheet.addMergedRegion(region2); sheet.addMergedRegion(region3); sheet.addMergedRegion(region4); sheet.addMergedRegion(region5); sheet.addMergedRegion(region6); sheet.addMergedRegion(region7); sheet.addMergedRegion(region8); sheet.addMergedRegion(region9); sheet.addMergedRegion(region10);
版权声明:本文为博主原创文章,未经博主允许不得转载。
The 'to' row (0) must not be less than the 'from' row (1)
时间: 2024-11-06 12:00:13