+ 2
Reading Microsoft word Table
How to import Microsoft word table into c# 2D array.
7 Answers
0
You can install Microsoft.Office.Interop.Word via the NuGetPackage managers
The type op wordApp is Microsoft.Office.Interop.Word.Application
This is code, I have tested succesfully.
It does not contain error handling and freeing of the word object.
You need to add that yourself.
Microsoft.Office.Interop.Word.Application myWordApplication = new Microsoft.Office.Interop.Word.Application();
myWordApplication.Visible = false;
Microsoft.Office.Interop.Word.Document myWordDocument = null;
object fileName = "c:\\temp\\WordTableTest.docx";
object readOnly = false;
object isVisible = false;
object missing = System.Reflection.Missing.Value;
myWordDocument = myWordApplication.Documents.Open(ref fileName, ref missing,
ref readOnly, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref isVisible, ref missing, ref missing, ref missing,
ref missing);
myWordDocument.ActiveWindow.Visible = false;
MessageBox.Show(myWordDocument.Tables.Count.ToString());
0
You solution is the Microsoft.Office.Interop.Word;
https://stackoverflow.com/questions/17484422/word-interop-using-tables
With the Microsoft interop you can load word documents and iterated through it collections and texts.
Open word document
wordDoc = wordApp.Documents.Open( <your filename>
Get the tables
int tablecount = wordDocument.Tables.Count;
Get a specific table
Word.Table wTable = wordDocument.Tables[i];
and make a loop to import the table in to your 2D array
0
Thank you sure. But it gives syntax error. How can I import wordApp and word Document ?
0
What is the type of wordApp?
0
Thank you very much and sorry i didnt reply to your sooner. Sorry to bother you but i have one more question .
Can you tell me about Microsoft.Office.Interop.
0
Microsoft.Office.Interop is a interface to Microsoft Word.
You can open a Word application within you c# application.
Or read the content of a Word document.
Does this anwer your question ?
0
actually I want to know about general things for Microsoft.Office.Interop? Not just for this program. pls