主题:请问,网页表格导出到word中的问题?
我现在有个程序可以把网页内普通的表格转化为word文档。但是我现在想把合并过单元格的表格转化为word文档,用该程序不行,怎么办?
该程序主要部分如下
Dim theArray(20,10000)
for i=0 to row-1
for j=0 to column-1
theArray(j+1,i+1) = table.rows(i).cells(j).innerTEXT
next
next
for i = 1 to column
objWordDoc.Application.ActiveDocument.Tables(1).Rows(1).Cells(i).Range.InsertAfter theArray(i,1)
objWordDoc.Application.ActiveDocument.Tables(1).Rows(1).Cells(i).Range.ParagraphFormat.alignment=1
next
For i =1 to column
For j = 2 to row
objWordDoc.Application.ActiveDocument.Tables(1).Rows(j).Cells(i).Range.InsertAfter theArray(i,j)
objWordDoc.Application.ActiveDocument.Tables(1).Rows(j).Cells(i).Range.ParagraphFormat.alignment=1
Next
Next
End Sub
我分析是由于该程序分行和列来读原表格,但是当我的表格内有合并过的单元格时(程序如下),就出错了。谁能帮忙?
<table width="75%" border="1">
<tr>
<td colspan="2">部门</td>
</tr>
<tr>
<td>1组</td>
<td>2组</td>
</tr>
</table>
该程序主要部分如下
Dim theArray(20,10000)
for i=0 to row-1
for j=0 to column-1
theArray(j+1,i+1) = table.rows(i).cells(j).innerTEXT
next
next
for i = 1 to column
objWordDoc.Application.ActiveDocument.Tables(1).Rows(1).Cells(i).Range.InsertAfter theArray(i,1)
objWordDoc.Application.ActiveDocument.Tables(1).Rows(1).Cells(i).Range.ParagraphFormat.alignment=1
next
For i =1 to column
For j = 2 to row
objWordDoc.Application.ActiveDocument.Tables(1).Rows(j).Cells(i).Range.InsertAfter theArray(i,j)
objWordDoc.Application.ActiveDocument.Tables(1).Rows(j).Cells(i).Range.ParagraphFormat.alignment=1
Next
Next
End Sub
我分析是由于该程序分行和列来读原表格,但是当我的表格内有合并过的单元格时(程序如下),就出错了。谁能帮忙?
<table width="75%" border="1">
<tr>
<td colspan="2">部门</td>
</tr>
<tr>
<td>1组</td>
<td>2组</td>
</tr>
</table>