Beispiel #1
0
        /// <summary>
        /// Jobシートのデータ埋めと書式あてこみメソッド
        /// </summary>
        /// <param name="book">ExcelBookオブジェクト</param>
        /// <param name="lists">HULFTジョブ定義データオブジェクト</param>
        /// <returns></returns>
        public bool UpdateJobBook(IWorkbook book, List <HulftJobDef> lists)
        {
            var sheet = book.GetSheet(ConstHulft.SHEETNAME_JOB);

            // セルに充てるスタイルの組み立て
            Dictionary <String, ICellStyle> styles = MyCreateStyles.CreateStyles(book);

            // 左上にシート名を
            WriteCell(sheet, styles["indexLabel"], (0, 0), ConstHulft.SHEETNAME_JOB);

            // データヘッダーの組み立て
            var header     = new HulftJobDef("Header");
            var headerList = header.GetListValues();

            // データヘッダーブロックの書き出し
            (int y, int x)p = (2, 1);
            headerList.Insert(0, "No.");
            for (int x = 0; x < headerList.Count; x++)
            {
                WriteCell(sheet, styles["indexLabel"], (p.y, p.x + x), headerList[x]);
            }
            sheet.SetAutoFilter(new CellRangeAddress(p.y, p.y, p.x, p.x + headerList.Count - 1));

            // データブロックの書き出し
            p = (3, 1);
            for (int y = 0; y < lists.Count; y++)
            {
                var dataList = lists[y].GetListValues();
                dataList.Insert(0, (y + 1).ToString());
                for (int x = 0; x < dataList.Count; x++)
                {
                    if (x == 1)
                    {
                        WriteCell(sheet, styles["defDataBa"], (p.y + y, p.x + x), dataList[x]);
                    }
                    else
                    {
                        WriteCell(sheet, styles["defData"], (p.y + y, p.x + x), dataList[x]);
                    }
                }
            }

            // カラムのAutoSize
            for (int x = 0; x < headerList.Count; x++)
            {
                sheet.AutoSizeColumn(p.x + x, true);
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// HULFTジョブ定義の文字列を解釈して、HulftJobDefクラスのListを生成して返す。
        /// </summary>
        /// <param name="HtmlText">HULFTジョブ定義文字列</param>
        /// <returns>HulftTGrpクラスのList</returns>
        public static List <HulftJobDef> StringBuildHulftJobDef(string HtmlText)
        {
            List <HulftJobDef> hulftJobDefs = new List <HulftJobDef>();
            HulftJobDef        hulftdef     = new HulftJobDef();

            using (StringReader sr = new StringReader(HtmlText))
            {
                string fileContent = "";
                bool   jobDef      = false;

                while ((fileContent = sr.ReadLine()) != null)
                {
                    //Debug.WriteLine(fileContent);
                    fileContent = fileContent.Trim();
                    if (fileContent == "")
                    {
                        continue;
                    }
                    if (fileContent == "#")
                    {
                        continue;
                    }


                    string[] array = fileContent.Split('=');
                    switch (array[0])
                    {
                    case "# ID":
                        hulftdef.ClearRest();
                        hulftdef.Id = array[1];
                        break;

                    case "JOB":
                        hulftdef.Job = array[1];
                        break;

                    case "COMMENT":
                        hulftdef.Comment = array[1];
                        break;

                    case "JOB DEF":
                        jobDef = true;
                        break;

                    case "DEFEND":
                        jobDef = false;
                        break;

                    case "END":
                        hulftJobDefs.Add(hulftdef.Clone());
                        break;
                    }

                    if (jobDef && array[0] != "JOB DEF")
                    {
                        hulftdef.JobList.Add(fileContent);
                        continue;
                    }
                }
            }

            return(hulftJobDefs);
        }