+ 2

Reading Microsoft word Table

How to import Microsoft word table into c# 2D array.

28th Sep 2018, 3:46 AM
Ган-Эрдэнэ
Ган-Эрдэнэ - avatar
7 odpowiedzi
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());
7th Oct 2018, 10:03 PM
sneeze
sneeze - avatar
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
29th Sep 2018, 7:42 PM
sneeze
sneeze - avatar
0
Thank you sure. But it gives syntax error. How can I import wordApp and word Document ?
6th Oct 2018, 2:50 PM
Ган-Эрдэнэ
Ган-Эрдэнэ - avatar
0
What is the type of wordApp?
6th Oct 2018, 3:28 PM
Ган-Эрдэнэ
Ган-Эрдэнэ - avatar
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.
7th Dec 2018, 4:56 PM
Ган-Эрдэнэ
Ган-Эрдэнэ - avatar
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 ?
7th Dec 2018, 8:43 PM
sneeze
sneeze - avatar
0
actually I want to know about general things for Microsoft.Office.Interop? Not just for this program. pls
10th Dec 2018, 2:00 AM
Ган-Эрдэнэ
Ган-Эрдэнэ - avatar