16,554
社区成员
发帖
与我相关
我的任务
分享
Private Sub excelt(fn As String)
Dim workbook As XSSFWorkbook
Using fs As FileStream = New FileStream(fn, FileMode.Open, FileAccess.Read)
workbook = New XSSFWorkbook(fs)
End Using
Dim sheet2 As ISheet = workbook.GetSheetAt(1)
Dim list As List(Of Double) = New List(Of Double)()
For i As Integer = 0 To sheet2.LastRowNum - 1
list.Add(sheet2.GetRow(i).GetCell(0).NumericCellValue)
Next
Dim sheet3 As ISheet = workbook.GetSheetAt(0)
Dim index As Integer = 0
For j As Integer = 1 To sheet3.LastRowNum
Dim Row As IRow = sheet3.GetRow(j)
Dim cell As ICell = If((Row.LastCellNum > 1S), Row.GetCell(1), Row.CreateCell(1))
cell.SetCellValue(list(index / 10))
index += 1
If index / 10 >= list.Count Then
Exit For
End If
Next
Using fs2 As FileStream = New FileStream(fn, FileMode.Create, FileAccess.Write)
workbook.Write(fs2)
End Using
End Sub