Zhlw.com - 中华龙网

站长资讯通告:
搜索: 您的位置中华龙网 > 计算机网络 > 认证考试 > 资格水平考试 > 文章列表

C++程序中导出Word文档的简易方法

作者:bear  来源:转载  发布时间:2005-12-16 11:38:02

  如果您要在应用程序中处理Word文档. Lori Turner. Automating Microsoft Office 97 and Office 2000,该文内容详细全面,但是要在C++

  //创建Word文档

  std::string create_new();

  //保存Word文档

  std::string close_save(const char* filename);

  //selection 往下移,以继续生成下一元素

  std::string move_down();

  //插入分段符

  std::string put_Paragraph();

  //添加标题

  std::string put_title(const char* title, const char* title_type="标题 1", int align=ALIGN_LEFT);

  //添加“标题1”

  std::string put_title1(const char* title, int align=ALIGN_CENTER);

  //添加“标题2”

  std::string put_title2(const char* title, int align=ALIGN_LEFT);

  //添加“标题3”

  std::string put_title3(const char* title, int align=ALIGN_LEFT);

  //添加红色警告信息

  std::string add_warning_msg(const char* msg="无数据");

  //添加表格的一行数据(不用此函数)

  std::string add_grid_ln(const char* line

  //添加表格

  std::string put_grid(const char* content);

  //运行脚本

  extern "C" void RunScript(const char* script_str);

  下面是一个小例子,我们期望它在您的计算机上能够很好的运行,程序将生成一个Word文档,路径位于c:\test.doc,计算机上需要安装Word XP。

  int main(int argc, char* argv[])

  {

  ostringstream ostr;

  ostr<

  ostr<

  ostr<

  std::string str_buffer;

  read_file_as_grid_content("tab.txt", str_buffer);

  ostr<

  ostr<

  ostr<

  //输出到文件看看VB脚本的内容

  /*

  std::ofstream ofile;

  ofile.open

  ofile<

  ofile.close();

  */

  //BeginWaitCursor();

  RunScript( ostr.str().c_str() );//运行生成的脚本

  //EndWaitCursor();

  return 0;

  }


  

        用户名: 验证码: 验证码,看不清楚?请点击刷新验证码 (注“”为必填内容。)


文章评论: [ 查看全部 ] 网友评论
关于本站 - 网站帮助 - 广告合作 - 友情连接 - 网站地图