Reading the Table cell data of word Document and writing to an excel file

hi guys,
In this artifact it would read the table cell data one by one fill into the build data table
and once it is filled it would write into excel file.

read of table is done using invoke code.

PFA the sample artifact with a sample docx file and one excel output file
create_table.zip (21.7 KB)

And if you want to do as reverse operation do find the code for that

++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dim obj As Object=System.Reflection.Missing.Value
Dim objEndofdocument As Object=“\endofdoc”
Dim appobj As Microsoft.Office.Interop.Word._Application=Nothing
Dim docoobj As Microsoft.Office.Interop.Word._Document=Nothing
appobj=New Microsoft.Office.Interop.Word.ApplicationClass
appobj.Visible=True
docoobj=appobj.Documents.Add(obj,obj,obj,obj)
Dim i As Integer=1
Dim j As Integer=1
Console.WriteLine(row.tostring)
Console.WriteLine(col.tostring)

Dim tableobj As Microsoft.Office.Interop.Word.Table
Dim rangeofword As Microsoft.Office.Interop.Word.Range
rangeofword=docoobj.Bookmarks.Item(objEndofdocument).Range
tableobj=docoobj.Tables.Add(rangeofword,row,col,obj,obj)
tableobj.Range.ParagraphFormat.SpaceAfter=2
tableobj.Borders.OutsideColor = WdColor.wdColorDarkRed
tableobj.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleDashDotDot
tableobj.Borders.InsideColor = WdColor.wdColorBrightGreen
tableobj.Borders.InsideLineStyle = WdLineStyle.wdLineStyleSingle

tableobj.Rows(1).Range.Font.Bold=1

While(i<=row)
j=1
While(j<=col)

tableobj.Cell(i,j).Range.Text=dt.Rows(i-1)(j-1).ToString
j=j+1

End While

i=i+1
End While

++++++++++++++++++++++++++++++++++++++++++++++++++++++

1 Like

hey,
i used your code ,it seem wrong . in your create_table folder , excel application scope , where is the test.xlsx file?