参考GitHub:https://github.com/crealytics/spark-excel
我使用了0.13.1版本的,此版本在读Excel时,必须指定文件,不能指定目录,否则报错。
<dependency>
<groupId>com.crealytics</groupId>
<artifactId>spark-excel_2.11</artifactId>
<version>0.13.1</version>
</dependency>
//读excel
spark.read.format("com.crealytics.spark.excel")
.option("header", "true").load(inputFile2)
//写excel
dataFrame.coalesce(1).write
.format("com.crealytics.spark.excel")
.option("dataAddress", "A1")
.option("header", "true")
.mode("overwrite")
.save(saveDir + "/" + fileName + "_" + dateStr + ".xlsx")