Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,
I have a database which stores Room related information (almost 50 columns), showing data for that particular Room, i.e. temperature, pressure, finish, name of the person living, room number etc. So each row has 50 columns which represents 50 properties of a room.
This database is created dynamically for each different building so no. of rooms are varying from building to building.
I want to import this data into .docx document with preformatted tables using content control. The .docx will have 5 different tables, on 5 seperate pages, in which one room specific data goes into. So for first room I can populate all table cells. No problem. I can place each table inside content control so I can get the correct table using tag information.
My question is how can I copy those 5 tables again so that I can eneter other room data in the same manner? The only way I can think of is to create tables programatically. But I think this will slow down the whole application, No?
Theoritically the way I see it working is add blank pages and then copy tables on to those blank pages. But unfortunately I dont know how to do this.

I want to do something like this.

http://msdn.microsoft.com/en-us/library/cc197932(v=office.12).aspx[^]

Basically, I want to generate a multi-page word document that shows all rooms information, lets say 100 rooms. So Each room information is divided in 5 pages (tables). So in total there will be 500 pages word document.

Thanks in anticipation of your help.
Regards
Posted
Updated 9-Jun-10 6:09am
v2

1 solution

Why don't you create a master copy of the (empty?) table, clone it when you need to, and add the cloned table to the document. Not knowing exactly why this is a problem, I can't suggest anything better.

You could also just create a class that builds the table for you with the data you provide, and instantiate it it with your datarow, and have it return a table.
 
Share this answer
 
v3
Comments
pfaudler 9-Jun-10 12:28pm    
Thanks very much John for your quick response and time.

The first option seems the way to go. can you please guide me how to do this, process wise? OR can you please direct me to a link where this is explained, i.e. how to clone table and then add that cloned table on a blank page.

I did think about the second option but I thought that this would slow down the application, No? Instead I thought I could start with a blank word .docx which has 5 pages setup with all necessary blank tables within content control. I would then clone each tables for each room data row. Will this be faster compare to initiating CreateTable class?

Thanks in anticipation of your help.

regards
#realJSOP 9-Jun-10 12:57pm    
I don't know. You're going to have to implement both and compare them. I would personally do option 2 because a) it's much easier to debug, and you have complete control of the code, but that's just me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900