Giter Club home page Giter Club logo

Comments (6)

nightscape avatar nightscape commented on June 16, 2024

My first guess would be that you're not yet using 0.9.0?

from spark-excel.

shashi4414 avatar shashi4414 commented on June 16, 2024

thanks for the replay nightscope .
we are using 0.9.0 version but when we writing got error like "scala.MatchError: null**"**

bellow is the code we are using to read and writing the file.
Reading File
Dataset df = sqlContext.read()
.format("com.crealytics.spark.excel")
.option("sheetName", "Sheet1") // Required
.option("useHeader", "true") // Required
.option("treatEmptyValuesAsNulls", "true") // Optional, default: true
.option("inferSchema", "false") // Optional, default: false
.option("addColorColumns", "false") // Optional, default: false
.option("startColumn", 0) // Optional, default: 0
.option("endColumn", 100) // Optional, default: Int.MaxValue
.load("D:\xls\demo.xlsx");
writing file.
df.write()
.format("com.crealytics.spark.excel")
.option("useHeader", "true")
.save("D:\xls\excelWrite.xlsx");

Error
Exception in thread "main" scala.MatchError: null
at com.crealytics.spark.excel.ExcelFileSaver.toCell(ExcelFileSaver.scala:28)
at com.crealytics.spark.excel.ExcelFileSaver$$anonfun$2$$anonfun$apply$1.apply(ExcelFileSaver.scala:19)
at com.crealytics.spark.excel.ExcelFileSaver$$anonfun$2$$anonfun$apply$1.apply(ExcelFileSaver.scala:19)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:35)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:245)
at scala.collection.AbstractTraversable.map(Traversable.scala:104)
at com.crealytics.spark.excel.ExcelFileSaver$$anonfun$2.apply(ExcelFileSaver.scala:19)
at com.crealytics.spark.excel.ExcelFileSaver$$anonfun$2.apply(ExcelFileSaver.scala:18)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:370)
at scala.collection.Iterator$class.foreach(Iterator.scala:742)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1194)
at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:59)
at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:183)
at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)
at scala.collection.TraversableOnce$class.to(TraversableOnce.scala:308)
at scala.collection.AbstractIterator.to(Iterator.scala:1194)
at scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:292)
at scala.collection.AbstractIterator.toList(Iterator.scala:1194)
at com.crealytics.spark.excel.ExcelFileSaver.save(ExcelFileSaver.scala:20)
at com.crealytics.spark.excel.DefaultSource.createRelation(DefaultSource.scala:71)
at org.apache.spark.sql.execution.datasources.DataSource.write(DataSource.scala:426)
at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:215)
at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:198)
at com.unilog.recordlinkage.action.HadoopOffice.main.

from spark-excel.

nightscape avatar nightscape commented on June 16, 2024

Ok, the toCell method does not actually handle nulls: https://github.com/crealytics/spark-excel/blob/master/src/main/scala/com/crealytics/spark/excel/ExcelFileSaver.scala#L28-L40
Would you mind creating a PR that does this?

from spark-excel.

shashi4414 avatar shashi4414 commented on June 16, 2024

ok,
so ho can i handle this issue.
please help me

from spark-excel.

nightscape avatar nightscape commented on June 16, 2024

If you dare to create a PR, that would be the best option and I would try to release a new version very soon.
If you don't, you can work around that issue by making sure that no column contains null values.
Third option is that you wait until we do the next round of improvements on this plugin and fix the issue.

from spark-excel.

nightscape avatar nightscape commented on June 16, 2024

Closing this as duplicate of #18 which has a better description of the null problem.

from spark-excel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.