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

版权声明:本文为博主原创文章,未经博主允许不得转载。

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

时间: 2024-11-06 12:00:13

The 'to' row (0) must not be less than the 'from' row (1)的相关文章

java.lang.IllegalStateException:Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx...}: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.  要检查列名拼写!列名拼

DataTables warning: TABLE id=DataTables_Table_0 - Requested UNKNOWN parameter '7' FOR ROW 0

使用H-ui.admin或者DataTables的人都难免会碰到: DataTables warning: TABLE id=DataTables_Table_0 - Requested UNKNOWN parameter '7' FOR ROW 0. FOR more information about this error, please see http://datatables.net/tn/4 此错误,结果去了DataTables官网手册也没看懂怎么解决. 耐着着急的赶项目的心,仔细去

DataTables warning : Requested unknown parameter '1' from the data source for row 0错误

昨天在做datatables的项目,从后台取得数据后,返回给datatables界面时会报下面的错误: DataTables warning : Requested unknown parameter '1' from the data source for row 0 加上下面的设置就可以了,至于原理还不是很清楚. "aoColumnDefs": [{ sDefaultContent: '', aTargets: [ '_all' ]  }], var oTable = $(&quo

java.lang.IllegalStateException: Couldn't read row 0, col 2 from CursorWindow.

java.lang.IllegalStateException: Couldn't read row 0, col 2 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it. 提示说没有找到相应的关键字段,查看数据库的字段是否写对,此时是区分大小写的 java.lang.IllegalStateException: Couldn't read row 0, c

DataTables warning: Requested unknown parameter '0' from the data source for row '0'

问题:DataTables warning: Requested unknown parameter '0' from the data source for row '0' 代码: <script type="text/javascript"> var data = [ {"Name":"UpdateBootProfile","Result":"PASS","ExecutionTim

Couldn&#39;t read row 0, col -1 from CursorWindow

java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it. c.getString(c.getColumnIndex("_ID")//字段名称不正确 Couldn't read row 0, col -1 from CursorWin

数据库Log之Couldn&#39;t read row 0, col -1 from CursorWindow

今天写代码,日志报出了一个很奇葩的错误.在CursorWindow的信息是Couldn't read row 0, col -1 这个错误一般是从sqlite查数据的时候照不到指定的列,或数据类型不匹配.避免这些低级错误最好养成良好的编程习惯,比如写成"cursor.getString(cursor.getColumnIndex("xxx"))"而不是"cursor.getString(3)". 再有的一点可能是db = dbHelper.get

DataTables warning: table id=dataTable - Requested unknown parameter &#39;acceptId&#39; for row 0. For more

重点内容 DataTables warning: table id=dataTable - Requested unknown parameter 'acceptId' for row 0. For more information about this error, please see http://datatables.net/tn/4 使用jquery.datatable时发生上面错误,配置如下: table = $("#dataTable").dataTable({ &quo

DataTables warning : Requested unknown parameter &#39;0&#39; from the data source for row 0错误

在做datatables的项目,从后台取得数据后,返回给datatables界面时会报下面的错误: DataTables warning : Requested unknown parameter '0' from the data source for row 0 加上下面的设置就可以了,至于原理还不是很清楚. "aoColumnDefs": [{ sDefaultContent: '', aTargets: [ '_all' ]  }], var oTable = $("