如有下面的中英文是交错排版的:
需要调整为并排排版,效果如下:
首先将交错排版的文本复制到Excel,如下:
编写VBA代码,将英文、中文分别放到单独的一列,并添加HTML代码,代码如下:
Sub 中英文并排显示()
Dim RowN As Long
Dim i As Long
Dim j As Long
j = 0
RowN = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To RowN Step 1
j = i * 2 - 1
ActiveSheet.Range("D" & i).Value = Range("A" & j).Value
ActiveSheet.Range("E" & i).Value = Range("A" & i * 2).Value
Next
For i = 1 To RowN / 2 Step 1
ActiveSheet.Range("F" & i).FormulaR1C1 = _
"=CONCATENATE(""<div class='layout'><p>"",RC[-2],""</p>"",""<p>"",RC[-1],""</p>"",""</div>"")"
Next
Range("F1:F" & (RowN / 2)).Select
End Sub
运行VBA代码后,Excel数据效果如下:
将F列的数据复制到html文档,并编写CSS代码,即可达到上述并排显示中英文的效果。
CSS代码细节请见:
-End-