How to export a Word document in a C ++ Program

Source: Internet
Author: User
The method for exporting Word documents in the C ++ Program-general Linux technology-Linux programming and kernel information. The following is a detailed description. If you want to process Word documents in the application, refer to MSDN. lori Turner. automating Microsoft Office 97 and Office 2000. The content of this article is comprehensive, but it is very troublesome to export Word documents in C ++ programs according to the methods in this article, in particular, we need to fill in too many parameters, so we should consider generating the correct VB script and then executing the Word document generation operation. The advantage of this method is that on the one hand, we can enter less parameters; on the other hand, macro scripts recorded in Word can be used, but only a few modifications are required. Some simple functions are provided to generate WORD Documents (mainly simple tables) and directly run the VB script in the memory. In addition, a small example is provided.

// Create a Word document
Std: string create_new ();
// Save the Word Document
Std: string close_save (const char * filename );
// Selection move down to continue generating the next element
Std: string move_down ();
// Insert a delimiter.
Std: string put_Paragraph ();
// Add a title
Std: string put_title (const char * title, const char * title_type = "title 1", int align = ALIGN_LEFT );
// Add "Title 1"
Std: string put_title1 (const char * title, int align = ALIGN_CENTER );
// Add "title 2"
Std: string put_title2 (const char * title, int align = ALIGN_LEFT );
// Add "Title 3"
Std: string put_title3 (const char * title, int align = ALIGN_LEFT );
// Add a red warning message
Std: string add_warning_msg (const char * msg = "no data ");
// Add a row of table data (this function is not required)
Std: string add_grid_ln (const char * line );
// Add a table
Std: string put_grid (const char * content );

// Run the script
Extern "C" void RunScript (const char * script_str );

The following is a small example. We expect it to run well on your computer. The program will generate a Word document with the path in c: \ test.doc. You need to install Word XP on your computer.

Int main (int argc, char * argv [])
{
Ostringstream ostr;
Ostr <
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.