Skip to content

ClassCast Exeption while reading XLSX files  #25

@prassee

Description

@prassee

While reading xlsx files the job throws ClassCastException. The artifact , sample code and error log is attached below.
(Note :- since this is not available in maven central I loaded the jar under lib dir)
Spark Version - 3.2.0
Scala Version - 2.12.15

  val s3Path    = s"s3a://.../*.xlsx"

  val xlsStmts = spark.read
    .format("com.elastacloud.spark.excel")
    .option("cellAddress", "A1") // The first line of the table starts at cell C3
    .option(
      "sheetNamePattern",
      """Xns"""
    )                           // Read data from all sheets matching this pattern (e.g. Sheet1 and Sheet3)
    .option("maxRowCount", 100) // Read only the first 10 records to determine the schema of the data
    .option("thresholdBytesForTempFiles", 50000000) // Setdd
    .load(s3Path)

Error Log

java.lang.ClassCastException: class org.apache.xmlbeans.impl.values.XmlComplexContentImpl 
cannot be cast to class elastashade.poi.schemas.vmldrawing.XmlDocument 

(org.apache.xmlbeans.impl.values.XmlComplexContentImpl and elastashade.poi    
.schemas.vmldrawing.XmlDocument are in unnamed module of loader java.net.URLClassLoader @10bf3464) at 
elastashade.poi.xssf.usermodel.XSSFVMLDrawing.read(XSS    FVMLDrawing.java:147) at 
elastashade.poi.xssf.usermodel.XSSFVMLDrawing.<init>(XSSFVMLDrawing.java:123) at 
elastashade.poi.ooxml.POIXMLFactory.createDocument    Part(POIXMLFactory.java:61) at 
elastashade.poi.ooxml.POIXMLDocumentPart.read(POIXMLDocumentPart.java:661) at 
elastashade.poi.ooxml.POIXMLDocumentPart.read(P    OIXMLDocumentPart.java:678) at 
elastashade.poi.ooxml.POIXMLDocument.load(POIXMLDocument.java:165) at 
elastashade.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSF    Workbook.java:259) at 
elastashade.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook( 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions