Ajay10795
Databricks Partner

Below code can be used

 

import org.apache.spark.sql.DataFrame

// Define the file path (modify this to your actual file path)
val filePath = "/dbfs/FileStore/tables/Airline.xlsx"

// Read the Excel file into a DataFrame
val df: DataFrame = spark.read
.format("com.crealytics.spark.excel")
.option("sheetName", "Sheet1") // Specify the sheet name if needed
.option("header", "true") // If the first row contains column names
.load(filePath)

// Show the DataFrame to verify the data
df.show()