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

刚开始以为是缺少解析包,就引入了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包完全够用了

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐