The 'to' row 0 must not be less than the 'from' row 1

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); 


 

 

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

上一篇:lucene&solr学习——索引维护


下一篇:OCP 12c最新考试原题及答案(071-5)