码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-11-04 17:53:53      阅读:1455      评论:0      收藏:0      [点我收藏+]

标签:java   excel   导出   

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)

标签:java   excel   导出   

原文地址:http://blog.csdn.net/you23hai45/article/details/49639011

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!