예제 #1
0
        internal static void CreateFieldTemplate()
        {
            #region 產生欄位表

            Aspose.Words.Document doc = new Aspose.Words.Document(new System.IO.MemoryStream(Properties.Resources.Template));
            Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
            int maxSubjectNum = 15;
            int maxStuNum = 60;

            builder.Font.Size = 8;
            #region 基本欄位
            builder.Writeln("基本欄位");
            builder.StartTable();
            foreach (string field in new string[] { "學年度", "學期", "學校名稱", "學校地址", "學校電話", "科別名稱", "定期評量", "班級", "班導師", "類別排名1", "類別排名2" })
            {
                builder.InsertCell();
                builder.Write(field);
                builder.InsertCell();
                builder.InsertField("MERGEFIELD " + field + " \\* MERGEFORMAT ", "«" + field + "»");
                builder.EndRow();
            }
            builder.EndTable();
            #endregion

            #region 科目成績
            builder.Writeln("科目成績");
            builder.StartTable();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("科目名稱");
            for (int i = 1; i <= maxSubjectNum; i++)
            {
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 科目名稱" + i + " \\* MERGEFORMAT ", "«科目名稱" + i + "»");
            }
            builder.EndRow();

            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("學分數");
            for (int i = 1; i <= maxSubjectNum; i++)
            {
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學分數" + i + " \\* MERGEFORMAT ", "«C" + i + "»");
            }
            builder.EndRow();

            for (int stuIndex = 1; stuIndex <= maxStuNum; stuIndex++)
            {
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學號" + stuIndex + " \\* MERGEFORMAT ", "«學號" + stuIndex + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 座號" + stuIndex + " \\* MERGEFORMAT ", "«座號" + stuIndex + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 姓名" + stuIndex + " \\* MERGEFORMAT ", "«姓名" + stuIndex + "»");
                for (int i = 1; i <= maxSubjectNum; i++)
                {
                    builder.InsertCell();
                    builder.InsertField("MERGEFIELD 科目成績" + stuIndex + "-" + i + " \\* MERGEFORMAT ", "«S" + i + "»");
                }
                builder.EndRow();
            }
            builder.EndTable();
            #endregion

            #region 科目成績排名
            foreach (string key in new string[] { "班", "科", "全校", "類別1", "類別2" })
            {
                builder.InsertBreak(Aspose.Words.BreakType.PageBreak);
                builder.Writeln("科目成績" + key + "排名");
                builder.StartTable();
                builder.InsertCell();
                builder.InsertCell();
                builder.InsertCell();
                builder.Write("科目名稱");
                for (int i = 1; i <= maxSubjectNum; i++)
                {
                    builder.InsertCell();
                    builder.InsertField("MERGEFIELD 科目名稱" + i + " \\* MERGEFORMAT ", "«科目名稱" + i + "»");
                }
                builder.EndRow();

                builder.InsertCell();
                builder.InsertCell();
                builder.InsertCell();
                builder.Write("學分數");
                for (int i = 1; i <= maxSubjectNum; i++)
                {
                    builder.InsertCell();
                    builder.InsertField("MERGEFIELD 學分數" + i + " \\* MERGEFORMAT ", "«C" + i + "»");
                }
                builder.EndRow();

                for (int stuIndex = 1; stuIndex <= maxStuNum; stuIndex++)
                {
                    builder.InsertCell();
                    builder.InsertField("MERGEFIELD 學號" + stuIndex + "\\* MERGEFORMAT ", "«學號" + stuIndex + "»");
                    builder.InsertCell();
                    builder.InsertField("MERGEFIELD 座號" + stuIndex + "\\* MERGEFORMAT ", "«座號" + stuIndex + "»");
                    builder.InsertCell();
                    builder.InsertField("MERGEFIELD 姓名" + stuIndex + "\\* MERGEFORMAT ", "«姓名" + stuIndex + "»");
                    for (int i = 1; i <= maxSubjectNum; i++)
                    {
                        builder.InsertCell();
                        builder.InsertField("MERGEFIELD " + key + "排名" + stuIndex + "-" + i + " \\* MERGEFORMAT ", "«RS»");
                        builder.InsertField("MERGEFIELD " + key + "排名母數" + stuIndex + "-" + i + " \\b /  \\* MERGEFORMAT ", "/«TS»");
                    }
                    builder.EndRow();
                }
                builder.EndTable();
            }
            #endregion

            #region 前次成績
            builder.InsertBreak(Aspose.Words.BreakType.PageBreak);
            builder.Writeln("前次成績");
            builder.StartTable();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("科目名稱");
            for (int i = 1; i <= maxSubjectNum; i++)
            {
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 科目名稱" + i + " \\* MERGEFORMAT ", "«科目名稱" + i + "»");
            }
            builder.EndRow();

            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("學分數");
            for (int i = 1; i <= maxSubjectNum; i++)
            {
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學分數" + i + " \\* MERGEFORMAT ", "«C" + i + "»");
            }
            builder.EndRow();

            for (int stuIndex = 1; stuIndex <= maxStuNum; stuIndex++)
            {
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學號" + stuIndex + " \\* MERGEFORMAT ", "«學號" + stuIndex + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 座號" + stuIndex + " \\* MERGEFORMAT ", "«座號" + stuIndex + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 姓名" + stuIndex + " \\* MERGEFORMAT ", "«姓名" + stuIndex + "»");
                for (int i = 1; i <= maxSubjectNum; i++)
                {
                    builder.InsertCell();
                    builder.InsertField("MERGEFIELD 前次成績" + stuIndex + "-" + i + " \\* MERGEFORMAT ", "«S" + i + "»");
                }
                builder.EndRow();
            }
            builder.EndTable();
            #endregion

            #region 總分、平均及排名
            builder.InsertBreak(Aspose.Words.BreakType.PageBreak);
            builder.Writeln("總分、平均及排名");
            builder.StartTable();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("總分");
            builder.InsertCell();
            builder.Write("總分班排名");
            builder.InsertCell();
            builder.Write("總分科排名");
            builder.InsertCell();
            builder.Write("總分校排名");
            builder.InsertCell();
            builder.Write("平均");
            builder.InsertCell();
            builder.Write("平均班排名");
            builder.InsertCell();
            builder.Write("平均科排名");
            builder.InsertCell();
            builder.Write("平均校排名");
            builder.EndRow();
            for (int stuIndex = 1; stuIndex <= maxStuNum; stuIndex++)
            {
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學號" + stuIndex + " \\* MERGEFORMAT ", "«學號" + stuIndex + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 座號" + stuIndex + " \\* MERGEFORMAT ", "«座號" + stuIndex + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 姓名" + stuIndex + "\\* MERGEFORMAT ", "«姓名" + stuIndex + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 總分" + stuIndex + " \\* MERGEFORMAT ", "«總分»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 總分班排名" + stuIndex + " \\* MERGEFORMAT ", "«RS»");
                builder.InsertField("MERGEFIELD 總分班排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "/«TS»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 總分科排名" + stuIndex + " \\* MERGEFORMAT ", "«RS»");
                builder.InsertField("MERGEFIELD 總分科排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "/«TS»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 總分全校排名" + stuIndex + " \\* MERGEFORMAT ", "«RS»");
                builder.InsertField("MERGEFIELD 總分全校排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "/«TS»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 平均" + stuIndex + " \\* MERGEFORMAT ", "«平均»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 平均班排名" + stuIndex + " \\* MERGEFORMAT ", "«RA»");
                builder.InsertField("MERGEFIELD 平均班排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "/«TA»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 平均科排名" + stuIndex + " \\* MERGEFORMAT ", "«RA»");
                builder.InsertField("MERGEFIELD 平均科排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "/«TA»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 平均全校排名" + stuIndex + " \\* MERGEFORMAT ", "«RA»");
                builder.InsertField("MERGEFIELD 平均全校排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "/«TA»");
                builder.EndRow();
            }
            builder.EndTable();
            #endregion

            #region 加權總分、加權平均及排名
            builder.InsertBreak(Aspose.Words.BreakType.PageBreak);
            builder.Writeln("加權總分、加權平均及排名");
            builder.StartTable();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("加權總分");
            builder.InsertCell();
            builder.Write("加權總分班排名");
            builder.InsertCell();
            builder.Write("加權總分科排名");
            builder.InsertCell();
            builder.Write("加權總分校排名");
            builder.InsertCell();
            builder.Write("加權平均");
            builder.InsertCell();
            builder.Write("加權平均班排名");
            builder.InsertCell();
            builder.Write("加權平均科排名");
            builder.InsertCell();
            builder.Write("加權平均校排名");
            builder.EndRow();
            for (int stuIndex = 1; stuIndex <= maxStuNum; stuIndex++)
            {
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學號" + stuIndex + " \\* MERGEFORMAT ", "«學號" + stuIndex + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 座號" + stuIndex + " \\* MERGEFORMAT ", "«座號" + stuIndex + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 姓名" + stuIndex + " \\* MERGEFORMAT ", "«姓名" + stuIndex + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 加權總分" + stuIndex + " \\* MERGEFORMAT ", "«總分»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 加權總分班排名" + stuIndex + " \\* MERGEFORMAT ", "«RS»");
                builder.InsertField("MERGEFIELD 加權總分班排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "/«TS»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 加權總分科排名" + stuIndex + " \\* MERGEFORMAT ", "«RS»");
                builder.InsertField("MERGEFIELD 加權總分科排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "/«TS»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 加權總分全校排名" + stuIndex + " \\* MERGEFORMAT ", "«RS»");
                builder.InsertField("MERGEFIELD 加權總分全校排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "/«TS»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 加權平均" + stuIndex + " \\* MERGEFORMAT ", "«平均»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 加權平均班排名" + stuIndex + " \\* MERGEFORMAT ", "«RA»");
                builder.InsertField("MERGEFIELD 加權平均班排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "/«TA»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 加權平均科排名" + stuIndex + " \\* MERGEFORMAT ", "«RA»");
                builder.InsertField("MERGEFIELD 加權平均科排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "/«TA»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 加權平均全校排名" + stuIndex + " \\* MERGEFORMAT ", "«RA»");
                builder.InsertField("MERGEFIELD 加權平均全校排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "/«TA»");
                builder.EndRow();
            }
            builder.EndTable();
            #endregion

            #region 類別1排名
            builder.InsertBreak(Aspose.Words.BreakType.PageBreak);
            builder.Writeln("類別1排名");
            builder.StartTable();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("總分");
            builder.InsertCell();
            builder.Write("總分排名");
            builder.InsertCell();
            builder.Write("平均");
            builder.InsertCell();
            builder.Write("平均排名");
            builder.InsertCell();
            builder.Write("加權總分");
            builder.InsertCell();
            builder.Write("加權總分排名");
            builder.InsertCell();
            builder.Write("加權平均");
            builder.InsertCell();
            builder.Write("加權平均排名");
            builder.EndRow();
            for (int stuIndex = 1; stuIndex <= maxStuNum; stuIndex++)
            {
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學號" + stuIndex + " \\* MERGEFORMAT ", "«學號" + stuIndex + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 座號" + stuIndex + " \\* MERGEFORMAT ", "«座號" + stuIndex + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 姓名" + stuIndex + " \\* MERGEFORMAT ", "«姓名" + stuIndex + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別1總分" + stuIndex + " \\* MERGEFORMAT ", "«類1總»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別1總分排名" + stuIndex + " \\* MERGEFORMAT ", "«RS»");
                builder.InsertField("MERGEFIELD 類別1總分排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "«/TS»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別1平均" + stuIndex + " \\* MERGEFORMAT ", "«類1均»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別1平均排名" + stuIndex + " \\* MERGEFORMAT ", "«RA»");
                builder.InsertField("MERGEFIELD 類別1平均排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "«/TA»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別1加權總分" + stuIndex + " \\* MERGEFORMAT ", "«類1加總»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別1加權總分排名" + stuIndex + " \\* MERGEFORMAT ", "«RP»");
                builder.InsertField("MERGEFIELD 類別1加權總分排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "«/TP»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別1加權平均" + stuIndex + " \\* MERGEFORMAT ", "«類1加均»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別1加權平均排名" + stuIndex + " \\* MERGEFORMAT ", "«RP»");
                builder.InsertField("MERGEFIELD 類別1加權平均排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "«/TP»");
                builder.EndRow();
            }
            builder.EndTable();
            #endregion

            #region 類別2排名
            builder.InsertBreak(Aspose.Words.BreakType.PageBreak);
            builder.Writeln("類別2排名");
            builder.StartTable();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("總分");
            builder.InsertCell();
            builder.Write("總分排名");
            builder.InsertCell();
            builder.Write("平均");
            builder.InsertCell();
            builder.Write("平均排名");
            builder.InsertCell();
            builder.Write("加權總分");
            builder.InsertCell();
            builder.Write("加權總分排名");
            builder.InsertCell();
            builder.Write("加權平均");
            builder.InsertCell();
            builder.Write("加權平均排名");
            builder.EndRow();
            for (int stuIndex = 1; stuIndex <= maxStuNum; stuIndex++)
            {
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學號" + stuIndex + " \\* MERGEFORMAT ", "«學號" + stuIndex + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 座號" + stuIndex + " \\* MERGEFORMAT ", "«座號" + stuIndex + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 姓名" + stuIndex + " \\* MERGEFORMAT ", "«姓名" + stuIndex + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別2總分" + stuIndex + " \\* MERGEFORMAT ", "«類1總»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別2總分排名" + stuIndex + " \\* MERGEFORMAT ", "«RS»");
                builder.InsertField("MERGEFIELD 類別2總分排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "«/TS»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別2平均" + stuIndex + " \\* MERGEFORMAT ", "«類1均»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別2平均排名" + stuIndex + " \\* MERGEFORMAT ", "«RA»");
                builder.InsertField("MERGEFIELD 類別2平均排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "«/TA»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別2加權總分" + stuIndex + " \\* MERGEFORMAT ", "«類1加總»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別2加權總分排名" + stuIndex + " \\* MERGEFORMAT ", "«RP»");
                builder.InsertField("MERGEFIELD 類別2加權總分排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "«/TP»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別2加權平均" + stuIndex + " \\* MERGEFORMAT ", "«類1加均»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別2加權平均排名" + stuIndex + " \\* MERGEFORMAT ", "«RP»");
                builder.InsertField("MERGEFIELD 類別2加權平均排名母數" + stuIndex + " \\b /  \\* MERGEFORMAT ", "«/TP»");
                builder.EndRow();
            }
            builder.EndTable();
            #endregion

            #region 各項科目成績分析
            foreach (string key in new string[] { "班", "科", "校", "類1", "類2" })
            {
                builder.InsertBreak(Aspose.Words.BreakType.PageBreak);

                builder.Writeln(key + "成績分析及組距");

                builder.StartTable();
                builder.InsertCell(); builder.Write("科目名稱");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD 科目名稱" + subjectIndex + " \\* MERGEFORMAT ", "«N" + subjectIndex + "»");
                }
                builder.EndRow();

                builder.InsertCell(); builder.Write("高標");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "高標" + subjectIndex + " \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("均標");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "均標" + subjectIndex + " \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("低標");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "低標" + subjectIndex + " \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("標準差");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "標準差" + subjectIndex + " \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("100以上");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count100Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("90以上");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count90Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("90以上小於100");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count90 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("小於90");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count90Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("80以上");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count80Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("80以上小於90");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count80 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("小於80");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count80Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("70以上");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count70Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("70以上小於80");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count70 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("小於70");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count70Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("60以上");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count60Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("60以上小於70");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count60 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");

                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("小於60");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count60Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("50以上");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count50Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("50以上小於60");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count50 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("小於50");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count50Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("40以上");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count40Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("40以上小於50");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count40 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("小於40");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count40Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("30以上");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count30Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("30以上小於40");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count30 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("小於30");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count30Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("20以上");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count20Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("20以上小於30");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count20 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("小於20");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count20Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("10以上");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count10Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("10以上小於20");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count10 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.InsertCell(); builder.Write("小於10");
                for (int subjectIndex = 1; subjectIndex <= maxSubjectNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count10Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                }
                builder.EndRow();
                builder.EndTable();
            }
            #endregion

            #region 加總成績分析
            builder.InsertBreak(Aspose.Words.BreakType.PageBreak);
            builder.Writeln("加總成績分析及組距");
            builder.StartTable();
            builder.InsertCell(); builder.Write("項目");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.Write(key);
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("高標");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "高標 \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("均標");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "均標 \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("低標");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "低標 \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("標準差");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "標準差 \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("100以上");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count100Up \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("90以上");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count90Up \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("90以上小於100");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count90 \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("小於90");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count90Down \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("80以上");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count80Up \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("80以上小於90");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count80 \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("小於80");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count80Down \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("70以上");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count70Up \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("70以上小於80");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count70 \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("小於70");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count70Down \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("60以上");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count60Up \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("60以上小於70");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count60 \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("小於60");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count60Down \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("50以上");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count50Up \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("50以上小於60");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count50 \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("小於50");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count50Down \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("40以上");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count40Up \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("40以上小於50");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count40 \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("小於40");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count40Down \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("30以上");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count30Up \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("30以上小於40");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count30 \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("小於30");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count30Down \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("20以上");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count20Up \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("20以上小於30");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count20 \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("小於20");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count20Down \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("10以上");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count10Up \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("10以上小於20");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count10 \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.InsertCell(); builder.Write("小於10");
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count10Down \\* MERGEFORMAT ", "«C»");
            }
            builder.EndRow();
            builder.EndTable();
            #endregion
            #endregion

            #region 儲存檔案
            string inputReportName = "班級評量成績單合併欄位總表";
            string reportName = inputReportName;

            string path = Path.Combine(System.Windows.Forms.Application.StartupPath, "Reports");
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
            path = Path.Combine(path, reportName + ".doc");

            if (File.Exists(path))
            {
                int i = 1;
                while (true)
                {
                    string newPath = Path.GetDirectoryName(path) + "\\" + Path.GetFileNameWithoutExtension(path) + (i++) + Path.GetExtension(path);
                    if (!File.Exists(newPath))
                    {
                        path = newPath;
                        break;
                    }
                }
            }

            try
            {
                doc.Save(path, Aspose.Words.SaveFormat.Doc);
                System.Diagnostics.Process.Start(path);
            }
            catch
            {
                System.Windows.Forms.SaveFileDialog sd = new System.Windows.Forms.SaveFileDialog();
                sd.Title = "另存新檔";
                sd.FileName = reportName + ".doc";
                sd.Filter = "Excel檔案 (*.doc)|*.doc|所有檔案 (*.*)|*.*";
                if (sd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    try
                    {
                        doc.Save(path, Aspose.Words.SaveFormat.Doc);
                    }
                    catch
                    {
                        FISCA.Presentation.Controls.MsgBox.Show("指定路徑無法存取。", "建立檔案失敗", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        return;
                    }
                }
            }
            #endregion
        }
예제 #2
0
파일: WordUtils.cs 프로젝트: waodng/VSIX
        /// <summary>
        /// 引用Aspose.Words.dll导出word数据库字典文档
        /// 注意:不依赖微软office办公软件
        /// </summary>
        /// <param name="databaseName"></param>
        /// <param name="tables"></param>
        public static void ExportWordByAsposeWords(string fileName, string databaseName, List <TableDto> tables)
        {
            Aspose.Words.Document doc = new Aspose.Words.Document();

            // TODO document properties
            doc.BuiltInDocumentProperties.Subject           = "设计文档";
            doc.BuiltInDocumentProperties.ContentType       = "数据库字典";
            doc.BuiltInDocumentProperties.Title             = "数据库字典文档";
            doc.BuiltInDocumentProperties.Author            = doc.BuiltInDocumentProperties.LastSavedBy = doc.BuiltInDocumentProperties.Manager = "trycache";
            doc.BuiltInDocumentProperties.Company           = "waodng";
            doc.BuiltInDocumentProperties.Version           = doc.BuiltInDocumentProperties.RevisionNumber = 1;
            doc.BuiltInDocumentProperties.ContentStatus     = "初稿";
            doc.BuiltInDocumentProperties.NameOfApplication = "DBCHM";
            doc.BuiltInDocumentProperties.LastSavedTime     = doc.BuiltInDocumentProperties.CreatedTime = System.DateTime.Now;

            // TODO header and footer setting
            Aspose.Words.HeaderFooter header = new Aspose.Words.HeaderFooter(doc, Aspose.Words.HeaderFooterType.HeaderPrimary);
            doc.FirstSection.HeadersFooters.Add(header);
            // Add a paragraph with text to the header.
            header.AppendParagraph("数据库字典文档").ParagraphFormat.Alignment =
                Aspose.Words.ParagraphAlignment.Right;
            Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, Aspose.Words.HeaderFooterType.FooterPrimary);
            doc.FirstSection.HeadersFooters.Add(footer);
            // Add a paragraph with text to the footer.
            footer.AppendParagraph(" 版权所有 @ waodng  ").ParagraphFormat.Alignment =
                Aspose.Words.ParagraphAlignment.Center;

            Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);

            // TODO 创建文档标题书签
            CreateBookmark(builder, Aspose.Words.ParagraphAlignment.Center, Aspose.Words.OutlineLevel.Level1, 25,
                           asposeBookmark_prefix + "0", "数据库字典文档");
            builder.ParagraphFormat.OutlineLevel = Aspose.Words.OutlineLevel.BodyText;
            builder.Writeln("—— " + databaseName);

            // TODO 换行
            builder.InsertBreak(Aspose.Words.BreakType.ParagraphBreak);
            builder.InsertBreak(Aspose.Words.BreakType.ParagraphBreak);
            builder.InsertBreak(Aspose.Words.BreakType.ParagraphBreak);

            // TODO 数据库字典文档修订日志表
            CreateBookmark(builder, Aspose.Words.ParagraphAlignment.Center, Aspose.Words.OutlineLevel.Level2, 16,
                           asposeBookmarkLog, AppConst.LOG_CHAPTER_NAME);
            CreateLogTable(builder);
            builder.InsertBreak(Aspose.Words.BreakType.PageBreak);

            // TODO 创建数据库字典文档数据库概况一览表
            CreateBookmark(builder, Aspose.Words.ParagraphAlignment.Center, Aspose.Words.OutlineLevel.Level2, 16,
                           asposeBookmarkOverview, AppConst.TABLE_CHAPTER_NAME);
            CreateOverviewTable(builder, tables);
            builder.InsertBreak(Aspose.Words.BreakType.PageBreak);

            // TODO 创建书签
            CreateBookmark(builder, Aspose.Words.ParagraphAlignment.Left, Aspose.Words.OutlineLevel.Level2, 16,
                           asposeBookmark_prefix + 0, AppConst.TABLE_STRUCTURE_CHAPTER_NAME);

            int i = 0; // 计数器

            // TODO 遍历数据库表集合
            foreach (var table in tables)
            {
                string bookmarkName = table.TableName + " " + (!string.IsNullOrWhiteSpace(table.Comment) ? table.Comment : "");

                // TODO 创建书签
                CreateBookmark(builder, Aspose.Words.ParagraphAlignment.Left, Aspose.Words.OutlineLevel.Level3, 16,
                               asposeBookmark_prefix + i, table.TableOrder + "、" + bookmarkName);

                // TODO 遍历数据库表字段集合
                // TODO 创建表格
                Aspose.Words.Tables.Table asposeTable = builder.StartTable();

                // 清除段落样式
                builder.ParagraphFormat.ClearFormatting();

                #region 表格列设置,列标题,列宽,字体等
                // Make the header row.
                builder.InsertCell();
                // Set the left indent for the table. Table wide formatting must be applied after
                // at least one row is present in the table.
                asposeTable.Alignment      = Aspose.Words.Tables.TableAlignment.Center;
                asposeTable.PreferredWidth = PreferredWidth.FromPercent(120);
                asposeTable.AllowAutoFit   = false;
                // Set height and define the height rule for the header row.
                builder.RowFormat.Height     = 40.0;
                builder.RowFormat.HeightRule = Aspose.Words.HeightRule.AtLeast;
                // Some special features for the header row.
                builder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.Color.FromArgb(198, 217, 241);
                builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Center;
                builder.Font.Size = 14;
                builder.Font.Name = "Arial";
                builder.Font.Bold = true;
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(8);
                builder.Write("序号");

                // We don't need to specify the width of this cell because it's inherited from the previous cell.
                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
                builder.Write("列名");

                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(12);
                builder.Write("数据类型");

                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(8);
                builder.Write("长度");

                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(8);
                builder.Write("小数位");

                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(8);
                builder.Write("主键");

                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(8);
                builder.Write("自增");

                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(8);
                builder.Write("允许空");

                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(10);
                builder.Write("默认值");

                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);
                builder.Write("列说明");
                builder.EndRow();
                #endregion

                foreach (var column in table.Columns)
                {
                    #region 遍历表格数据行写入
                    // Set features for the other rows and cells.
                    builder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.Color.White;
                    builder.CellFormat.Width             = 100.0;
                    builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;
                    //builder.CellFormat.FitText = true;
                    // Reset height and define a different height rule for table body
                    builder.RowFormat.Height     = 60.0;
                    builder.RowFormat.HeightRule = Aspose.Words.HeightRule.AtLeast;
                    builder.InsertCell();
                    // Reset font formatting.
                    builder.Font.Size = 12;
                    builder.Font.Bold = false;
                    builder.Write(column.ColumnOrder); // 序号

                    builder.InsertCell();
                    builder.Write(column.ColumnName); // 列名

                    builder.InsertCell();
                    builder.Write(column.ColumnTypeName); // 数据类型

                    builder.InsertCell();
                    builder.Write(column.Length); // 长度

                    builder.InsertCell();
                    builder.Write(column.Scale); // 小数位

                    builder.InsertCell();
                    builder.Write(column.IsPK); // 主键

                    builder.InsertCell();
                    builder.Write(column.IsIdentity); // 自增

                    builder.InsertCell();
                    builder.Write(column.CanNull); // 是否为空

                    builder.InsertCell();
                    builder.Font.Size = 10;
                    builder.Write(column.DefaultVal); // 默认值

                    builder.InsertCell();
                    builder.Font.Size = 10;
                    builder.Write(column.Comment); // 列说明

                    builder.EndRow();
                    #endregion
                }

                // TODO 表格创建完成,结束
                //asposeTable.PreferredWidth = Aspose.Words.Tables.PreferredWidth.Auto;
                //asposeTable.AutoFit(Aspose.Words.Tables.AutoFitBehavior.AutoFitToContents);
                builder.EndTable();

                i++;

                // TODO page breaks
                if (i < tables.Count)
                {
                    builder.InsertBreak(Aspose.Words.BreakType.PageBreak);
                }
            }

            // TODO 添加水印
            //InsertWatermarkText(doc, "DBCHM-51Try.Top");

            doc.Save(fileName);
        }
예제 #3
0
        internal static void CreateFieldTemplate()
        {
            #region 產生欄位表
            Aspose.Words.Document doc = new Aspose.Words.Document(new System.IO.MemoryStream(Properties.Resources.Template));
            Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
            int maxNum = 30;

            #region 科目學期學年評量成績
            builder.Writeln("成績");
            builder.StartTable();
            builder.InsertCell();
            builder.Write("科目名稱");
            builder.InsertCell();
            builder.Write("學分數");
            builder.InsertCell();
            builder.Write("評量參考成績");
            builder.InsertCell();
            builder.Write("評量成績");
            builder.InsertCell();
            builder.Write("學年成績");
            builder.InsertCell();
            builder.Write("學期成績");
            builder.InsertCell();
            builder.Write("上學期成績");

            builder.InsertCell();
            builder.Write("學期科目原始成績");
            builder.InsertCell();
            builder.Write("學期科目補考成績");
            builder.InsertCell();
            builder.Write("學期科目重修成績");
            builder.InsertCell();
            builder.Write("學期科目手動調整成績");
            builder.InsertCell();
            builder.Write("學期科目學年調整成績");

            builder.InsertCell();
            builder.Write("上學期科目原始成績");
            builder.InsertCell();
            builder.Write("上學期科目補考成績");
            builder.InsertCell();
            builder.Write("上學期科目重修成績");
            builder.InsertCell();
            builder.Write("上學期科目手動調整成績");
            builder.InsertCell();
            builder.Write("上學期科目學年調整成績");
            builder.EndRow();
            for (int i = 1; i <= maxNum; i++)
            {
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 科目名稱" + i + " \\* MERGEFORMAT ", "«N" + i + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學分數" + i + " \\* MERGEFORMAT ", "«C" + i + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 前次成績" + i + " \\* MERGEFORMAT ", "«SP" + i + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 科目成績" + i + " \\* MERGEFORMAT ", "«S" + i + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學年科目成績" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學期科目成績" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 上學期科目成績" + i + " \\* MERGEFORMAT ", "«R»");

                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學期科目原始成績" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學期科目補考成績" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學期科目重修成績" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學期科目手動調整成績" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學期科目學年調整成績" + i + " \\* MERGEFORMAT ", "«R»");

                builder.InsertCell();
                builder.InsertField("MERGEFIELD 上學期科目原始成績" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 上學期科目補考成績" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 上學期科目重修成績" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 上學期科目手動調整成績" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 上學期科目學年調整成績" + i + " \\* MERGEFORMAT ", "«R»");

                builder.EndRow();
            }

            builder.EndTable();
            builder.Write("固定變數");
            builder.StartTable();
            builder.InsertCell();
            builder.Write("項目");
            builder.InsertCell();
            builder.Write("變數");
            builder.EndRow();
            foreach (string key in new string[]{
                    "學期學業成績"
                    ,"學期體育成績"
                    ,"學期國防通識成績"
                    ,"學期健康與護理成績"
                    ,"學期實習科目成績"
                    ,"學期德行成績"
                    ,"學期學業成績班排名"
                    ,"上學期學業成績"
                    ,"上學期體育成績"
                    ,"上學期國防通識成績"
                    ,"上學期健康與護理成績"
                    ,"上學期實習科目成績"
                    ,"上學期德行成績"
                    ,"學年學業成績"
                    ,"學年體育成績"
                    ,"學年國防通識成績"
                    ,"學年健康與護理成績"
                    ,"學年實習科目成績"
                    ,"學年德行成績"
                    ,"學年學業成績班排名"
                    ,"導師評語"
                    ,"大功統計"
                    ,"小功統計"
                    ,"嘉獎統計"
                    ,"大過統計"
                    ,"小過統計"
                    ,"警告統計"
                    ,"留校察看"
                    ,"班導師"
                })
            {
                builder.InsertCell();
                builder.Write(key);
                builder.InsertCell();
                builder.InsertField("MERGEFIELD " + key + " \\* MERGEFORMAT ", "«" + key + "»");
                builder.EndRow();
            }
            foreach (var key in new string[] { "班", "科", "類別1", "類別2", "校" })
            {
                builder.InsertCell();
                builder.Write("學期學業成績" + key + "排名");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學期學業成績" + key + "排名 \\* MERGEFORMAT ", "«學期學業成績" + key + "排名»");
                builder.InsertField("MERGEFIELD 學期學業成績" + key + "排名母數 \\b /  \\* MERGEFORMAT ", "/«學期學業成績" + key + "排名母數»");
                builder.EndRow();
            }
            builder.EndTable();
            #endregion

            #region 學期科目成績排名
            builder.Writeln("學期科目成績排名");
            builder.StartTable();
            builder.InsertCell();
            builder.Write("科目名稱");
            builder.InsertCell();
            builder.Write("學期科目排名成績");
            builder.InsertCell();
            builder.Write("學期科目班排名");
            builder.InsertCell();
            builder.Write("學期科目科排名");
            builder.InsertCell();
            builder.Write("學期科目類別1排名");
            builder.InsertCell();
            builder.Write("學期科目類別2排名");
            builder.InsertCell();
            builder.Write("學期科目全校排名");
            builder.EndRow();
            for (int i = 1; i <= maxNum; i++)
            {
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 科目名稱" + i + " \\* MERGEFORMAT ", "«N" + i + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學期科目排名成績" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學期科目班排名" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertField("MERGEFIELD 學期科目班排名母數" + i + " \\b /  \\* MERGEFORMAT ", "/«T»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學期科目科排名" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertField("MERGEFIELD 學期科目科排名母數" + i + " \\b /  \\* MERGEFORMAT ", "/«T»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學期科目類別1排名" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertField("MERGEFIELD 學期科目類別1排名母數" + i + " \\b /  \\* MERGEFORMAT ", "/«T»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學期科目類別2排名" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertField("MERGEFIELD 學期科目類別2排名母數" + i + " \\b /  \\* MERGEFORMAT ", "/«T»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學期科目全校排名" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertField("MERGEFIELD 學期科目全校排名母數" + i + " \\b /  \\* MERGEFORMAT ", "/«T»");
                builder.EndRow();
            }
            builder.EndTable();
            #endregion

            #region 科目成績及排名
            builder.Writeln("科目成績及排名");
            builder.StartTable();
            builder.InsertCell();
            builder.Write("科目名稱");
            builder.InsertCell();
            builder.Write("學分數");
            builder.InsertCell();
            builder.Write("前次成績");
            builder.InsertCell();
            builder.Write("科目成績");
            builder.InsertCell();
            builder.Write("班排名");
            builder.InsertCell();
            builder.Write("科排名");
            builder.InsertCell();
            builder.Write("類別1排名");
            builder.InsertCell();
            builder.Write("類別2排名");
            builder.InsertCell();
            builder.Write("全校排名");
            builder.EndRow();
            for (int i = 1; i <= maxNum; i++)
            {
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 科目名稱" + i + " \\* MERGEFORMAT ", "«N" + i + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 學分數" + i + " \\* MERGEFORMAT ", "«C" + i + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 前次成績" + i + " \\* MERGEFORMAT ", "«SP" + i + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 科目成績" + i + " \\* MERGEFORMAT ", "«S" + i + "»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 班排名" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertField("MERGEFIELD 班排名母數" + i + " \\b /  \\* MERGEFORMAT ", "/«T»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 科排名" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertField("MERGEFIELD 科排名母數" + i + " \\b /  \\* MERGEFORMAT ", "/«T»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別1排名" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertField("MERGEFIELD 類別1排名母數" + i + " \\b /  \\* MERGEFORMAT ", "/«T»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 類別2排名" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertField("MERGEFIELD 類別2排名母數" + i + " \\b /  \\* MERGEFORMAT ", "/«T»");
                builder.InsertCell();
                builder.InsertField("MERGEFIELD 全校排名" + i + " \\* MERGEFORMAT ", "«R»");
                builder.InsertField("MERGEFIELD 全校排名母數" + i + " \\b /  \\* MERGEFORMAT ", "/«T»");
                builder.EndRow();
            }

            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("項目");
            builder.InsertCell();
            builder.Write("成績");
            builder.InsertCell();
            builder.Write("班排名");
            builder.InsertCell();
            builder.Write("科排名");
            builder.InsertCell();
            builder.Write("類別1排名");
            builder.InsertCell();
            builder.Write("類別2排名");
            builder.InsertCell();
            builder.Write("全校排名");
            builder.EndRow();

            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("總分");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 總分 \\* MERGEFORMAT ", "«總分»");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 總分班排名 \\* MERGEFORMAT ", "«RS»");
            builder.InsertField("MERGEFIELD 總分班排名母數 \\b /  \\* MERGEFORMAT ", "/«TS»");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 總分科排名 \\* MERGEFORMAT ", "«RS»");
            builder.InsertField("MERGEFIELD 總分科排名母數 \\b /  \\* MERGEFORMAT ", "/«TS»");
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 總分全校排名 \\* MERGEFORMAT ", "«RS»");
            builder.InsertField("MERGEFIELD 總分全校排名母數 \\b /  \\* MERGEFORMAT ", "/«TS»");
            builder.EndRow();

            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("平均");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 平均 \\* MERGEFORMAT ", "«平均»");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 平均班排名 \\* MERGEFORMAT ", "«RA»");
            builder.InsertField("MERGEFIELD 平均班排名母數 \\b /  \\* MERGEFORMAT ", "/«TA»");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 平均科排名 \\* MERGEFORMAT ", "«RA»");
            builder.InsertField("MERGEFIELD 平均科排名母數 \\b /  \\* MERGEFORMAT ", "/«TA»");
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 平均全校排名 \\* MERGEFORMAT ", "«RA»");
            builder.InsertField("MERGEFIELD 平均全校排名母數 \\b /  \\* MERGEFORMAT ", "/«TA»");
            builder.EndRow();

            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("加權總分");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 加權總分 \\* MERGEFORMAT ", "«加權總»");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 加權總分班排名 \\* MERGEFORMAT ", "«RP»");
            builder.InsertField("MERGEFIELD 加權總分班排名母數 \\b /  \\* MERGEFORMAT ", "/«TP»");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 加權總分科排名 \\* MERGEFORMAT ", "«RP»");
            builder.InsertField("MERGEFIELD 加權總分科排名母數 \\b /  \\* MERGEFORMAT ", "/«TP»");
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 加權總分全校排名 \\* MERGEFORMAT ", "«RP»");
            builder.InsertField("MERGEFIELD 加權總分全校排名母數 \\b /  \\* MERGEFORMAT ", "/«TP»");
            builder.EndRow();

            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("加權平均");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 加權平均 \\* MERGEFORMAT ", "«加權均»");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 加權平均班排名 \\* MERGEFORMAT ", "«RP»");
            builder.InsertField("MERGEFIELD 加權平均班排名母數 \\b /  \\* MERGEFORMAT ", "/«TP»");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 加權平均科排名 \\* MERGEFORMAT ", "«RP»");
            builder.InsertField("MERGEFIELD 加權平均科排名母數 \\b /  \\* MERGEFORMAT ", "/«TP»");
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 加權平均全校排名 \\* MERGEFORMAT ", "«RP»");
            builder.InsertField("MERGEFIELD 加權平均全校排名母數 \\b /  \\* MERGEFORMAT ", "/«TP»");
            builder.EndRow();

            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("類1總分");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 類別1總分 \\* MERGEFORMAT ", "«類1總»");
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 類別1總分排名 \\* MERGEFORMAT ", "«RS»");
            builder.InsertField("MERGEFIELD 類別1總分排名母數 \\b /  \\* MERGEFORMAT ", "«/TS»");
            builder.InsertCell();
            builder.InsertCell();
            builder.EndRow();

            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("類1平均");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 類別1平均 \\* MERGEFORMAT ", "«類1均»");
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 類別1平均排名 \\* MERGEFORMAT ", "«RA»");
            builder.InsertField("MERGEFIELD 類別1平均排名母數 \\b /  \\* MERGEFORMAT ", "«/TA»");
            builder.InsertCell();
            builder.InsertCell();
            builder.EndRow();

            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("類1加權總分");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 類別1加權總分 \\* MERGEFORMAT ", "«類1加總»");
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 類別1加權總分排名 \\* MERGEFORMAT ", "«RP»");
            builder.InsertField("MERGEFIELD 類別1加權總分排名母數 \\b /  \\* MERGEFORMAT ", "«/TP»");
            builder.InsertCell();
            builder.InsertCell();
            builder.EndRow();

            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("類1加權平均");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 類別1加權平均 \\* MERGEFORMAT ", "«類1加均»");
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 類別1加權平均排名 \\* MERGEFORMAT ", "«RP»");
            builder.InsertField("MERGEFIELD 類別1加權平均排名母數 \\b /  \\* MERGEFORMAT ", "«/TP»");
            builder.InsertCell();
            builder.InsertCell();
            builder.EndRow();

            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("類2總分");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 類別2總分 \\* MERGEFORMAT ", "«類2總»");
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 類別2總分排名 \\* MERGEFORMAT ", "«RS»");
            builder.InsertField("MERGEFIELD 類別2總分排名母數 \\b /  \\* MERGEFORMAT ", "«/TS»");
            builder.InsertCell();
            builder.EndRow();

            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("類2平均");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 類別2平均 \\* MERGEFORMAT ", "«類2均»");
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 類別2平均排名 \\* MERGEFORMAT ", "«RA»");
            builder.InsertField("MERGEFIELD 類別2平均排名母數 \\b /  \\* MERGEFORMAT ", "«/TA»");
            builder.InsertCell();
            builder.EndRow();

            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("類2加權總分");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 類別2加權總分 \\* MERGEFORMAT ", "«類2加總»");
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 類別2加權總分排名 \\* MERGEFORMAT ", "«RP»");
            builder.InsertField("MERGEFIELD 類別2加權總分排名母數 \\b /  \\* MERGEFORMAT ", "«/TP»");
            builder.InsertCell();
            builder.EndRow();

            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.Write("類2加權平均");
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 類別2加權平均 \\* MERGEFORMAT ", "«類2加均»");
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertCell();
            builder.InsertField("MERGEFIELD 類別2加權平均排名 \\* MERGEFORMAT ", "«RP»");
            builder.InsertField("MERGEFIELD 類別2加權平均排名母數 \\b /  \\* MERGEFORMAT ", "«/TP»");
            builder.InsertCell();
            builder.EndRow();

            builder.EndTable();
            #endregion

            #region 各項科目成績分析
            foreach (string key in new string[] { "班", "科", "校", "類1", "類2" })
            {
                builder.InsertBreak(Aspose.Words.BreakType.PageBreak);

                builder.Writeln(key + "成績分析及組距");

                builder.StartTable();
                builder.InsertCell(); builder.Write("科目名稱");
                builder.InsertCell(); builder.Write("高標");
                builder.InsertCell(); builder.Write("均標");
                builder.InsertCell(); builder.Write("低標");
                builder.InsertCell(); builder.Write("標準差");
                builder.InsertCell(); builder.Write("100以上");
                builder.InsertCell(); builder.Write("90以上");
                builder.InsertCell(); builder.Write("80以上");
                builder.InsertCell(); builder.Write("70以上");
                builder.InsertCell(); builder.Write("60以上");
                builder.InsertCell(); builder.Write("50以上");
                builder.InsertCell(); builder.Write("40以上");
                builder.InsertCell(); builder.Write("30以上");
                builder.InsertCell(); builder.Write("20以上");
                builder.InsertCell(); builder.Write("10以上");
                builder.EndRow();
                for (int subjectIndex = 1; subjectIndex <= maxNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD 科目名稱" + subjectIndex + " \\* MERGEFORMAT ", "«N" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "高標" + subjectIndex + " \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "均標" + subjectIndex + " \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "低標" + subjectIndex + " \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "標準差" + subjectIndex + " \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count100Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count90Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count80Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count70Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count60Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count50Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count40Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count30Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count20Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count10Up \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.EndRow();
                }
                builder.EndTable();

                builder.InsertBreak(Aspose.Words.BreakType.PageBreak);
                builder.StartTable();
                builder.InsertCell(); builder.Write("科目名稱");
                builder.InsertCell(); builder.Write("高標");
                builder.InsertCell(); builder.Write("均標");
                builder.InsertCell(); builder.Write("低標");
                builder.InsertCell(); builder.Write("標準差");
                builder.InsertCell(); builder.Write("90以上小於100");
                builder.InsertCell(); builder.Write("80以上小於90");
                builder.InsertCell(); builder.Write("70以上小於80");
                builder.InsertCell(); builder.Write("60以上小於70");
                builder.InsertCell(); builder.Write("50以上小於60");
                builder.InsertCell(); builder.Write("40以上小於50");
                builder.InsertCell(); builder.Write("30以上小於40");
                builder.InsertCell(); builder.Write("20以上小於30");
                builder.InsertCell(); builder.Write("10以上小於20");
                builder.EndRow();
                for (int subjectIndex = 1; subjectIndex <= maxNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD 科目名稱" + subjectIndex + " \\* MERGEFORMAT ", "«N" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "高標" + subjectIndex + " \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "均標" + subjectIndex + " \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "低標" + subjectIndex + " \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "標準差" + subjectIndex + " \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count90 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count80 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count70 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count60 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count50 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count40 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count30 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count20 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count10 \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.EndRow();
                }
                builder.EndTable();

                builder.InsertBreak(Aspose.Words.BreakType.PageBreak);
                builder.StartTable();
                builder.InsertCell(); builder.Write("科目名稱");
                builder.InsertCell(); builder.Write("高標");
                builder.InsertCell(); builder.Write("均標");
                builder.InsertCell(); builder.Write("低標");
                builder.InsertCell(); builder.Write("標準差");
                builder.InsertCell(); builder.Write("小於90");
                builder.InsertCell(); builder.Write("小於80");
                builder.InsertCell(); builder.Write("小於70");
                builder.InsertCell(); builder.Write("小於60");
                builder.InsertCell(); builder.Write("小於50");
                builder.InsertCell(); builder.Write("小於40");
                builder.InsertCell(); builder.Write("小於30");
                builder.InsertCell(); builder.Write("小於20");
                builder.InsertCell(); builder.Write("小於10");
                builder.EndRow();
                for (int subjectIndex = 1; subjectIndex <= maxNum; subjectIndex++)
                {
                    builder.InsertCell(); builder.InsertField("MERGEFIELD 科目名稱" + subjectIndex + " \\* MERGEFORMAT ", "«N" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "高標" + subjectIndex + " \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "均標" + subjectIndex + " \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "低標" + subjectIndex + " \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "標準差" + subjectIndex + " \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count90Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count80Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count70Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count60Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count50Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count40Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count30Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count20Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距" + subjectIndex + "count10Down \\* MERGEFORMAT ", "«C" + subjectIndex + "»");
                    builder.EndRow();
                }
                builder.EndTable();
            }
            #endregion

            #region 加總成績分析
            builder.Writeln("加總成績分析及組距");

            builder.InsertBreak(Aspose.Words.BreakType.PageBreak);
            builder.StartTable();
            builder.InsertCell(); builder.Write("項目");
            builder.InsertCell(); builder.Write("高標");
            builder.InsertCell(); builder.Write("均標");
            builder.InsertCell(); builder.Write("低標");
            builder.InsertCell(); builder.Write("標準差");
            builder.InsertCell(); builder.Write("100以上");
            builder.InsertCell(); builder.Write("90以上");
            builder.InsertCell(); builder.Write("80以上");
            builder.InsertCell(); builder.Write("70以上");
            builder.InsertCell(); builder.Write("60以上");
            builder.InsertCell(); builder.Write("50以上");
            builder.InsertCell(); builder.Write("40以上");
            builder.InsertCell(); builder.Write("30以上");
            builder.InsertCell(); builder.Write("20以上");
            builder.InsertCell(); builder.Write("10以上");
            builder.EndRow();
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.Write(key);
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "高標 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "均標 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "低標 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "標準差 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count100Up \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count90Up \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count80Up \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count70Up \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count60Up \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count50Up \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count40Up \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count30Up \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count20Up \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count10Up \\* MERGEFORMAT ", "«C»");
                builder.EndRow();
            }
            builder.EndTable();
            builder.InsertBreak(Aspose.Words.BreakType.PageBreak);
            builder.StartTable();
            builder.InsertCell(); builder.Write("項目");
            builder.InsertCell(); builder.Write("高標");
            builder.InsertCell(); builder.Write("均標");
            builder.InsertCell(); builder.Write("低標");
            builder.InsertCell(); builder.Write("標準差");
            builder.InsertCell(); builder.Write("90以上小於100");
            builder.InsertCell(); builder.Write("80以上小於90");
            builder.InsertCell(); builder.Write("70以上小於80");
            builder.InsertCell(); builder.Write("60以上小於70");
            builder.InsertCell(); builder.Write("50以上小於60");
            builder.InsertCell(); builder.Write("40以上小於50");
            builder.InsertCell(); builder.Write("30以上小於40");
            builder.InsertCell(); builder.Write("20以上小於30");
            builder.InsertCell(); builder.Write("10以上小於20");
            builder.EndRow();
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.Write(key);
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "高標 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "均標 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "低標 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "標準差 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count90 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count80 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count70 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count60 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count50 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count40 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count30 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count20 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count10 \\* MERGEFORMAT ", "«C»");
                builder.EndRow();
            }
            builder.EndTable();
            builder.InsertBreak(Aspose.Words.BreakType.PageBreak);
            builder.StartTable();
            builder.InsertCell(); builder.Write("項目");
            builder.InsertCell(); builder.Write("高標");
            builder.InsertCell(); builder.Write("均標");
            builder.InsertCell(); builder.Write("低標");
            builder.InsertCell(); builder.Write("標準差");
            builder.InsertCell(); builder.Write("小於90");
            builder.InsertCell(); builder.Write("小於80");
            builder.InsertCell(); builder.Write("小於70");
            builder.InsertCell(); builder.Write("小於60");
            builder.InsertCell(); builder.Write("小於50");
            builder.InsertCell(); builder.Write("小於40");
            builder.InsertCell(); builder.Write("小於30");
            builder.InsertCell(); builder.Write("小於20");
            builder.InsertCell(); builder.Write("小於10");
            builder.EndRow();
            foreach (string key in new string[] { "總分班", "總分科", "總分校", "平均班", "平均科", "平均校", "加權總分班", "加權總分科", "加權總分校", "加權平均班", "加權平均科", "加權平均校", "類1總分", "類1平均", "類1加權總分", "類1加權平均", "類2總分", "類2平均", "類2加權總分", "類2加權平均" })
            {
                builder.InsertCell(); builder.Write(key);
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "高標 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "均標 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "低標 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "標準差 \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count90Down \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count80Down \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count70Down \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count60Down \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count50Down \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count40Down \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count30Down \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count20Down \\* MERGEFORMAT ", "«C»");
                builder.InsertCell(); builder.InsertField("MERGEFIELD " + key + "組距count10Down \\* MERGEFORMAT ", "«C»");
                builder.EndRow();
            }
            builder.EndTable();
            #endregion
            #endregion

            #region 儲存檔案
            string inputReportName = "個人評量成績單合併欄位總表";
            string reportName = inputReportName;

            string path = Path.Combine(System.Windows.Forms.Application.StartupPath, "Reports");
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
            path = Path.Combine(path, reportName + ".doc");

            if (File.Exists(path))
            {
                int i = 1;
                while (true)
                {
                    string newPath = Path.GetDirectoryName(path) + "\\" + Path.GetFileNameWithoutExtension(path) + (i++) + Path.GetExtension(path);
                    if (!File.Exists(newPath))
                    {
                        path = newPath;
                        break;
                    }
                }
            }

            try
            {
                doc.Save(path, Aspose.Words.SaveFormat.Doc);
                System.Diagnostics.Process.Start(path);
            }
            catch
            {
                System.Windows.Forms.SaveFileDialog sd = new System.Windows.Forms.SaveFileDialog();
                sd.Title = "另存新檔";
                sd.FileName = reportName + ".doc";
                sd.Filter = "Excel檔案 (*.doc)|*.doc|所有檔案 (*.*)|*.*";
                if (sd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    try
                    {
                        doc.Save(path, Aspose.Words.SaveFormat.Doc);
                    }
                    catch
                    {
                        FISCA.Presentation.Controls.MsgBox.Show("指定路徑無法存取。", "建立檔案失敗", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        return;
                    }
                }
            }
            #endregion
        }