private static void FillDoc(HSSFWorkbook workbook, IStringParams prms)
        {
            if (prms == null)
            {
                return;
            }

            for (int i = 0; i < workbook.NumberOfNames; i++)
            {
                var name  = workbook.GetNameAt(i);
                var value = prms.Get(name.NameName);

                if (String.IsNullOrEmpty(value))
                {
                    continue;
                }

                try
                {
                    var cellRef = new CellReference(name.RefersToFormula);
                    var sheet   = workbook.GetSheet(cellRef.SheetName);
                    var row     = sheet.GetRow(cellRef.Row);
                    var cell    = row.GetCell(cellRef.Col);

                    cell.SetCellValue(value);
                }
                catch (Exception)
                {
                }
            }
        }
Exemplo n.º 2
0
        private static void FillDoc(DocumentBuilder builder, IStringParams prms)
        {
            if (prms == null)
            {
                return;
            }

            foreach (var fieldName in builder.GetFieldNames())
            {
                var value = prms.Get(fieldName);

                if (String.IsNullOrEmpty(value))
                {
                    continue;
                }

                builder.SetField(fieldName, value);
            }
        }