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-05 17:18:33 发布