zoukankan      html  css  js  c++  java
  • Aspose.Words 总结

    生成答题卡

    try
    {
    string tempPath = @"D:moban tt.doc";

    //Open document and create Documentbuilder
    //Aspose.Words.Document doc = new Aspose.Words.Document();
    //DocumentBuilder builder = new DocumentBuilder(doc);
    //Set table formating
    //Set borders
    // builder.CellFormat.Borders.LineStyle = LineStyle.Single;
    //builder.CellFormat.Borders.Color = Color.Red;
    //Set left indent
    //builder.RowFormat.LeftIndent = 100;
    //builder.MoveToCell(0, 2, i, 0); //移动单元格
    // etc...
    //Move documentBuilder cursor to the bookmark
    //builder.MoveToBookmark("myBookmark");
    //Insert some table

    //builder.RowFormat.Height = 20;
    //builder.CellFormat.Width = 10;
    //builder.InsertCell();
    //builder.EndTable();

    string t1 = "D:\moban\temp1.doc";
    string t2 = "D:\moban\temp2.doc";
    Document dstDoc = new Document(t1);

    DocumentBuilder builder = new DocumentBuilder(dstDoc);
    for (int i = 0; i < 5; i++)
    {
    Document edite = new Document(t2);
    String[] key = new String[] { "titles" };
    Object[] value = new Object[] { i + "(5分)" };
    //合并模版,相当于页面的渲染
    edite.MailMerge.Execute(key, value);

    edite.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;
    dstDoc.AppendDocument(edite, ImportFormatMode.KeepSourceFormatting);
    }

    //使用域的方式填充数据
    String[] fieldNames = new String[] { "dtkname", "d01", "d02", "d03", "d04", "d05", "d06", "d07", "d08", "d09", "d10", "d11", "d12", "d13", "d14", "d15", "d01a", "d02a", "d03a", "d04a", "d05a", "d06a", "d07a", "d08a", "d09a", "d10a", "d11a", "d12a", "d13a", "d14a", "d15a", "titles" };
    Object[] fieldValues = new Object[] { "物理月考试卷", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "", "3(5分)" };
    //合并模版,相当于页面的渲染
    dstDoc.MailMerge.Execute(fieldNames, fieldValues);
    dstDoc.Save(tempPath);

    }
    catch (Exception)
    {

    throw;
    }

  • 相关阅读:
    LOJ 6089 小Y的背包计数问题 —— 前缀和优化DP
    洛谷 P1969 积木大赛 —— 水题
    洛谷 P1965 转圈游戏 —— 快速幂
    洛谷 P1970 花匠 —— DP
    洛谷 P1966 火柴排队 —— 思路
    51Nod 1450 闯关游戏 —— 期望DP
    洛谷 P2312 & bzoj 3751 解方程 —— 取模
    洛谷 P1351 联合权值 —— 树形DP
    NOIP2007 树网的核
    平面最近点对(加强版)
  • 原文地址:https://www.cnblogs.com/lijiasnong/p/5067503.html
Copyright © 2011-2022 走看看