[Lorg/openxmlformats/schemas/spreadsheetml/x2006/main/CTPhoneticRun报错

目录

前言

使用问题记录

总结



前言

接口自动化中的数据驱动采取的数据载体之一就是excel

其中广泛使用的excel jar包为apache poi相关的jar包,常用poi 、poi-ooxml两个包


使用问题记录

问题1 :

由于类型使用错误导致的报错问题,为了正确读取excel内容,通过cellType的类型获取单元格内容,但是在应该使用字符串类型的时候,错误的没有进行toString()操作,导致我在拼接成map之后,在想要转成jsonObject的时候,报错

case STRING:
    return cell.getRichStringCellValue();


错误信息:
Exception in thread "main" java.lang.NoClassDefFoundError: [Lorg/openxmlformats/schemas/spreadsheetml/x2006/main/CTPhoneticRun;

[Lorg/openxmlformats/schemas/spreadsheetml/x2006/main/CTPhoneticRun报错

刚开始以为是缺少解析包,就引入了poi-ooxml-full全部的包

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml-full</artifactId>
    <version>5.0.0</version>
</dependency>

之后发现错误信息变成这个
Exception in thread "main" com.alibaba.fastjson.JSONException: write javaBean error, fastjson version 1.2.76, class org.apache.xmlbeans.impl.schema.SchemaTypeImpl, fieldName : _schema_type, write javaBean error, fastjson version 1.2.76, class org.apache.xmlbeans.impl.schema.SchemaTypeImpl, fieldName : baseType 

 后来把问题聚焦 at com.alibaba.fastjson.serializer.ASMSerializer_1_XSSFRichTextString.write(Unknown Source)
时候,就想到了是拼接map的时候的去内容这块报错了,应该使用

return cell.getRichStringCellValue().toString();


总结

就是不细心引起来的问题,poi 及poi-ooxml包完全够用了

上一篇:Diagnostic and programming Interface


下一篇:eclipse代码提示增强