• 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;
    }

  • 相关阅读:
    HTML语义化
    OKAY take it away `electron-builder`一直提示这个
    gitbash选中不了自己想要的选择
    vue挂载
    vue关闭eslint
    第二天-5大浏览器内核和浏览器的组成
    第一天-JavaScript简介与历史
    bootstrap模态框遇到做复制的功能失效
    对象的key【键】和分别获取数组的key【键】和值
    AngularJS教程
  • 原文地址:https://www.cnblogs.com/lijiasnong/p/5067503.html
Copyright © 2020-2023  润新知