使用 smartxls api 从 excel 读取控件无效

Reading control from excel using smartxls api is not working

我试图从 excel 文件中读取表单控件。 我正在使用 smartXLS api.

在我的 excel 文件单元格 "c2" 中有列表框 (formControl)。 现在我想读那个控件。

我尝试了以下代码,但它抛出了异常

workBook.readXLSX("D:\TestAssessment.xlsx");

//This row throws an exception.
//Here I was passed parameters in function as getFormControl(rowIndex,columnIndex)
FormControlShape fm = (FormControlShape)workBook.getFormControl(1, 2);

谁能知道为什么会抛出异常?

getFormControl(int type, int index) 
          get the specified index formcontrol from the current sheet

这是描述方法的smartXLS javadoc。参数int type表示表单控件的类型;类型:20-ComBox 11-CheckBox 18-ListBox。参数int index表示表单控件的索引。

希望对您有所帮助。

我已阅读 SmartXLS javaDoc。

FormControlShape shape = workBook.getFormControl(FormControlShape.ListBox, listBoxId);

// Here FormControlShape is inbuilt enum for to pass which type of form control you need to read/get.
// listBoxId is integer for index of the form control.