I want to check that all tables in a document have a table title. Please see the image below for the error details: unable to cast object of type Aspose.Words.Tables.Table to type Microsoft.Office.Interop.Word.Table. How else can I achieve this please?
I had already tried that and found that I couldn’t access the title property. How do I access it from an Aspose table please?
Also I need to be able to insert an entire file into the row of a table and was unsure the best way to go about, i.e. do I copy the contents of one file to insert into the table row or can I simply insert the whole file? Also what happens if the file to be inserted is a single table row (i.e. a table with one row), how do I insert that entire row into a table in another document with the same columns?
To ensure a timely and accurate response, please attach the following resources here for testing:
Your input Word document.
Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.
As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.
PS: To attach these resources, please zip and upload them.
Please move the cursor to the desired table’s cell and insert the document using DocumentBuilder.InsertDocument method.
Apologies for the delayed reply, I have been waiting on someone to provide me with proper sample data but it just hasn’t happened, so I’ve created a tiny sample of how I’m presuming it will be.
Attached are 2 documents. I want to add the entire contents of the insertion document into the first empty row of the table in the main document that has the title “Test Table 2”.
Thanks so much that is very helpful, however I will not know at runtime how many tables are in the destination document nor which order the tables are in, I will only know the title of the table so I will need to be able to identify it via the title not the order number.
You can implement IReplacingCallback interface and find the matched node (Run node) of table’s title. Once you have node of table’s title, you can get the table using Node.NextSibling property. We suggest you please read the following articles. Aspose.Words Document Object Model Find and Replace
Thank you however I’m still unsure how to implement this. I have attached 2 documents as examples to show you what I am trying to achieve.
For the purposes of this exercise let’s say I want to insert the contents of the Row Sample document into the table with the title ‘Table Two Title’ in the Table Sample document.
Please note that we do not provide support for older released versions of Aspose.Words. Moreover, we do not provide any fixes or patches for old versions of Aspose products either. All fixes and new features are always added into new versions of our products.
Just one more query, regarding your last code sample, you don’t appear to be checking for the table title as per my requirements. Please can you clarify how that works? Thanks
In your document, the table title is the paragraph before the table. The code example finds the table’s title and insert the table’s row. Please refer to the following article. Find and Replace
Could you please share some more detail about your requirement and expected output document? We will then provide you more information about your query along with code example.
No my table title is not the paragraph before the table. Title is actually a property of a table within Word. If you right click and look at the properties of the table you will see the title.