如果您可以在 excel 中执行此操作,则以下代码应该适合您:
Sub SplitCellsAndExtend_Old()
'takes cells with inside line feeds and creates new row for each.
Dim strCell As String, lastRow As Long, i As Long, j As Long
application.ScreenUpdating = False
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = lastRow To 1 Step -1
strCell = Cells(i, 1)
j = 0
Do While InStr(1, strCell, Chr(10)) > 0
Rows(i + j + 1).Insert
strCell = Right(strCell, Len(strCell) - InStr(1, strCell, Chr(10)))
Cells(i + j, 1) = Left(Cells(i + j, 1).Value, InStr(1, Cells(i + j, 1), Chr(10)) - 1)
Cells(i + j + 1, 1).Value = strCell
Cells(i + j + 1, 1).Value = Cells(i, 1)
j = j + 1
Loop
Next
application.ScreenUpdating = True
End Sub