Ejemplo n.º 1
0
        public static XWPFDocument SaveWord(List <RollList> list)
        {
            if (!System.IO.File.Exists(_modelBlackPath))
            {
                return(null);
            }
            XWPFDocument doc = _modelBlackPath.OpenWord();

            if (doc != null)
            {
                var paras = doc.Paragraphs;
                foreach (var para in paras)
                {
                    var text = para.ParagraphText;
                    var runs = para.Runs;
                    for (var i = 0; i < runs.Count; i++)
                    {
                        var run = runs[i];
                        var str = run.Text.Replace("{Time}", DateTime.Now.ToLongDateString());
                        run.SetText(str);
                    }
                }
                var tables = doc.Tables;
                var table  = tables[0];

                var modelrow  = table.GetRow(0);
                var startline = 1;
                foreach (var item in list)
                {
                    XWPFTableRow row = table.GetRow(startline);
                    if (row == null)
                    {
                        row = table.CreateRow();
                    }
                    var run = ExcelManager.GetRun(row, 0, modelrow);
                    run.SetText((startline++).ToString());
                    ExcelManager.GetRun(row, 1, modelrow).SetText(item.Name);
                    if (item.ConductStandards != null)
                    {
                        var array  = item.ConductStandards.Select(e => e.ContractNumber).Distinct().ToArray();
                        var array2 = item.ConductStandards.Select(e => string.Format("{0},应记{1}分", e.StandardName, e.Score)).ToArray();
                        ExcelManager.GetRun(row, 2, modelrow).SetText(string.Join(";", array));
                        ExcelManager.GetRun(row, 4, modelrow).SetText(item.ConductStandards.Sum(e => e.Area).ToString());
                        ExcelManager.GetRun(row, 5, modelrow).SetText(array2.Length > 0? string.Format("涉及{0}", string.Join(";", array2)):"");
                    }
                }
            }
            return(doc);
        }
Ejemplo n.º 2
0
        private static void Write(List <RollList> list, ref ISheet sheet, IRow modelRow)
        {
            var startLine = 2;
            var serial    = 1;

            foreach (var item in list)
            {
                var row = sheet.GetRow(startLine);
                if (row == null)
                {
                    row = sheet.CreateRow(startLine);
                }
                startLine++;
                var cell = ExcelManager.GetCell(row, 0, modelRow);
                cell.SetCellValue(serial++);
                ExcelManager.GetCell(row, 1, modelRow).SetCellValue(item.Name);
            }
        }
Ejemplo n.º 3
0
        private static void Write <T>(List <T> list, ref ISheet sheet, IRow modelRow) where T : BaseScore
        {
            var startLine = 1;

            foreach (var item in list)
            {
                var row = sheet.GetRow(startLine);
                if (row == null)
                {
                    row = sheet.CreateRow(startLine);
                }
                startLine++;
                var cell = ExcelManager.GetCell(row, 0, modelRow);
                cell.SetCellValue(item.Name);
                ExcelManager.GetCell(row, 1, modelRow).SetCellValue(item.Times.HasValue ? item.Times.Value : 0);
                ExcelManager.GetCell(row, 2, modelRow).SetCellValue(item.ScoreValue ?? 0);
                ExcelManager.GetCell(row, 3, modelRow).SetCellValue(item.Average);
                ExcelManager.GetCell(row, 4, modelRow).SetCellValue(item.Record ?? 0);
                ExcelManager.GetCell(row, 5, modelRow).SetCellValue(item.DeDuck);
                ExcelManager.GetCell(row, 6, modelRow).SetCellValue(item.Degree.ToString());
            }
        }