Skip to main content
Shawn Waldie
Dec 16, 2022 12:00 PM UTC

Creating a Word document with tables

I'm in the very beginning stages of designing/developing a program that will create a file or files that can be opened/imported by Word to display multiple tables like these (screenshot from a word document):

I can handle part that has to calculate these details.

However, i'm not sure what my options are for generating a file that can be imported/read by Word.

It appears that Word can handle XML documents, so I'm wondering if that would be worth researching.

Our current process is very labor intensive and requires a lot of hands-on, so ideally, my program would generate the file(s), and Word could then open and display the info seen above with minimal manual massaging.

Any ideas would be appreciated.



------------------------------
Shawn Waldie
enterprise application developer
Rocket Forum Shared Account
Los Angeles CA US
------------------------------

    15 replies

    Participating Frequently
    Dec 16, 2022 12:33 PM UTC
    I'm in the very beginning stages of designing/developing a program that will create a file or files that can be opened/imported by Word to display multiple tables like these (screenshot from a word document):

    I can handle part that has to calculate these details.

    However, i'm not sure what my options are for generating a file that can be imported/read by Word.

    It appears that Word can handle XML documents, so I'm wondering if that would be worth researching.

    Our current process is very labor intensive and requires a lot of hands-on, so ideally, my program would generate the file(s), and Word could then open and display the info seen above with minimal manual massaging.

    Any ideas would be appreciated.



    ------------------------------
    Shawn Waldie
    enterprise application developer
    Rocket Forum Shared Account
    Los Angeles CA US
    ------------------------------
    Is Excel not available?

    ------------------------------
    Marcus Rhodes
    marcus1@thinqware.com
    ------------------------------
    Shawn Waldie
    Dec 16, 2022 1:44 PM UTC
    Is Excel not available?

    ------------------------------
    Marcus Rhodes
    marcus1@thinqware.com
    ------------------------------
    The users are expecting a Word document.

    ------------------------------
    Shawn Waldie
    enterprise application developer
    Rocket Forum Shared Account
    Los Angeles CA US
    ------------------------------
    Participating Frequently
    Dec 16, 2022 2:30 PM UTC
    The users are expecting a Word document.

    ------------------------------
    Shawn Waldie
    enterprise application developer
    Rocket Forum Shared Account
    Los Angeles CA US
    ------------------------------
    If it must be Word, something I've done in the past is create a .rtf document containing placeholders for the data.  Then just read the .rtf file, swap in the data, and write the results out to a network share.  If the columns/rows are not constant, then you have to get a bit craftier with your Pick code, to add those fields to the .rtf, but I'm pretty sure it can be done.

    ------------------------------
    Marcus Rhodes
    marcus1@thinqware.com
    ------------------------------
    Henry Unger
    Participating Frequently
    Dec 16, 2022 3:17 PM UTC
    If it must be Word, something I've done in the past is create a .rtf document containing placeholders for the data.  Then just read the .rtf file, swap in the data, and write the results out to a network share.  If the columns/rows are not constant, then you have to get a bit craftier with your Pick code, to add those fields to the .rtf, but I'm pretty sure it can be done.

    ------------------------------
    Marcus Rhodes
    marcus1@thinqware.com
    ------------------------------
    I have not tried this, but if it were doing it I would explore something similar to the RTF approach, but take a docx file that would act as the template, unzip it, grab the word/document.xml file, swap in your table, and zip it back up again.

    ------------------------------
    Henry Unger
    President
    Hitech Systems Inc
    Encino CA US
    ------------------------------
    Doug Averch
    Inspiring
    Dec 16, 2022 4:21 PM UTC
    I'm in the very beginning stages of designing/developing a program that will create a file or files that can be opened/imported by Word to display multiple tables like these (screenshot from a word document):

    I can handle part that has to calculate these details.

    However, i'm not sure what my options are for generating a file that can be imported/read by Word.

    It appears that Word can handle XML documents, so I'm wondering if that would be worth researching.

    Our current process is very labor intensive and requires a lot of hands-on, so ideally, my program would generate the file(s), and Word could then open and display the info seen above with minimal manual massaging.

    Any ideas would be appreciated.



    ------------------------------
    Shawn Waldie
    enterprise application developer
    Rocket Forum Shared Account
    Los Angeles CA US
    ------------------------------
    There is an open-source product from Eclipse called BIRT that can output print jobs from Universe/Unidata in DOCX format. If you look at the BIRT gallery you will find some pretty cool examples. BTW BIRT can output PDF, HTML, and XLXS as well.

    Posted: 12-16-2022 16:20

    ------------------------------
    Doug Averch
    Owner
    U2 Logic
    ------------------------------
    Doug Averch Owner https://www.u2logic.com/
    Shawn Waldie
    Dec 16, 2022 4:34 PM UTC
    I have not tried this, but if it were doing it I would explore something similar to the RTF approach, but take a docx file that would act as the template, unzip it, grab the word/document.xml file, swap in your table, and zip it back up again.

    ------------------------------
    Henry Unger
    President
    Hitech Systems Inc
    Encino CA US
    ------------------------------

    Thank you @M Arcus1 and @Henry Unger !

    I'll definitely explore the rtf suggestions.​​



    ------------------------------
    Shawn Waldie
    enterprise application developer
    Rocket Forum Shared Account
    Los Angeles CA US
    ------------------------------
    David Green
    Inspiring
    Dec 17, 2022 7:54 AM UTC
    I'm in the very beginning stages of designing/developing a program that will create a file or files that can be opened/imported by Word to display multiple tables like these (screenshot from a word document):

    I can handle part that has to calculate these details.

    However, i'm not sure what my options are for generating a file that can be imported/read by Word.

    It appears that Word can handle XML documents, so I'm wondering if that would be worth researching.

    Our current process is very labor intensive and requires a lot of hands-on, so ideally, my program would generate the file(s), and Word could then open and display the info seen above with minimal manual massaging.

    Any ideas would be appreciated.



    ------------------------------
    Shawn Waldie
    enterprise application developer
    Rocket Forum Shared Account
    Los Angeles CA US
    ------------------------------
    We use AdvancedWare AWForms to do this kind of thing.  Very easy to use and very nice output.  We've changed all our outward facing forms to use AWForms, Invoices, Sales Orders, POs, RMAs, etc.

    They use the same technology that others on the list have suggested by creating an RTF form and having placeholders like SO_NBR, SO_DATE etc.  Then in your program you assign these variables.

    ------------------------------
    David Green
    Computer Programmer
    Rocket Forum Shared Account
    ------------------------------
    Mark Sapp
    Rocketeer
    Dec 19, 2022 10:18 AM UTC
    I'm in the very beginning stages of designing/developing a program that will create a file or files that can be opened/imported by Word to display multiple tables like these (screenshot from a word document):

    I can handle part that has to calculate these details.

    However, i'm not sure what my options are for generating a file that can be imported/read by Word.

    It appears that Word can handle XML documents, so I'm wondering if that would be worth researching.

    Our current process is very labor intensive and requires a lot of hands-on, so ideally, my program would generate the file(s), and Word could then open and display the info seen above with minimal manual massaging.

    Any ideas would be appreciated.



    ------------------------------
    Shawn Waldie
    enterprise application developer
    Rocket Forum Shared Account
    Los Angeles CA US
    ------------------------------
    Shawn,

    Many moons ago, I had used this simple little trick to 'create' word documents:  
    • Create the document with HTML formatting, which I assume is how you are creating the tables. This should not require fully-formed HTML, you can  create the doc file with just the fragment needed for the table, like the <table...> ...  </table> content.
    • Save the file with a ".doc"  extension (not docx)
    Word may ask the end user if they want to use word as their default HTML editor the first time they open the file  (answer: No, but it probably won't matter for end-users).  Obviously, a form creation tool would give you more options and functionality. This should work in a pinch, but test first to insure this will actually work for you!

    ------------------------------
    Mark Sapp
    Senior Software Developer
    Rocket Internal - All Brands
    ------------------------------
    Shawn Waldie
    Dec 19, 2022 11:24 AM UTC
    Shawn,

    Many moons ago, I had used this simple little trick to 'create' word documents:  
    • Create the document with HTML formatting, which I assume is how you are creating the tables. This should not require fully-formed HTML, you can  create the doc file with just the fragment needed for the table, like the <table...> ...  </table> content.
    • Save the file with a ".doc"  extension (not docx)
    Word may ask the end user if they want to use word as their default HTML editor the first time they open the file  (answer: No, but it probably won't matter for end-users).  Obviously, a form creation tool would give you more options and functionality. This should work in a pinch, but test first to insure this will actually work for you!

    ------------------------------
    Mark Sapp
    Senior Software Developer
    Rocket Internal - All Brands
    ------------------------------
    Another good idea. Thank you.

    Since I don't know what I'm looking at/for when reading in a binary file, finding the buckets to update in an html file might have a shallower learning curve, since it's a simple text file.

    ------------------------------
    Shawn Waldie
    enterprise application developer
    Rocket Forum Shared Account
    Los Angeles CA US
    ------------------------------
    Mark Baldridge
    Participating Frequently
    Dec 19, 2022 3:44 PM UTC
    I'm in the very beginning stages of designing/developing a program that will create a file or files that can be opened/imported by Word to display multiple tables like these (screenshot from a word document):

    I can handle part that has to calculate these details.

    However, i'm not sure what my options are for generating a file that can be imported/read by Word.

    It appears that Word can handle XML documents, so I'm wondering if that would be worth researching.

    Our current process is very labor intensive and requires a lot of hands-on, so ideally, my program would generate the file(s), and Word could then open and display the info seen above with minimal manual massaging.

    Any ideas would be appreciated.



    ------------------------------
    Shawn Waldie
    enterprise application developer
    Rocket Forum Shared Account
    Los Angeles CA US
    ------------------------------
    Word can read Open Document Format files. They are well defined from either Open Office, Apache, or Libre Office.

    ------------------------------
    Mark A Baldridge
    Principal Consultant
    Thought Mirror
    Nacogdoches, Texas United States
    ------------------------------