import java.io.{File, FileInputStream}
import org.apache.poi.ss.usermodel.CellType
import org.apache.poi.xssf.usermodel.XSSFWorkbook
object ExcelReaderScala {
def main(args: Array[String]): Unit = {
val myFile = new File("D:\\xx.xlsx")
val fis = new FileInputStream(myFile)
val myWorkbook = new XSSFWorkbook(fis)
val mySheet = myWorkbook.getSheetAt(0)
val lastNum=mySheet.getLastRowNum
for (a<- 0 to lastNum){
val row=mySheet.getRow(a)
val metaid=row.getCell(0)
metaid.setCellType(CellType.STRING)
val metaidI=metaid.getStringCellValue
val ottcode=row.getCell(1)
ottcode.setCellType(CellType.STRING)
val ottcodeI=ottcode.getStringCellValue
val ottparentcode=row.getCell(2)
ottparentcode.setCellType(CellType.STRING)
val ottparentcodeI=ottparentcode.getStringCellValue
println(metaidI
scala 读取Excel 实例
最新推荐文章于 2024-06-01 08:36:22 发布
本文详细介绍了如何在Scala项目中读取Excel文件,包括所需的库、步骤和实例代码,帮助开发者掌握这一实用技巧。
摘要由CSDN通过智能技术生成