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)
                {
                }
            }
        }
Example #2
0
        public byte[] Generate(Guid docId, string fileName, IStringParams prms)
        {
            using (var stream = new MemoryStream())
            {
                using (var documentBuilder = new DocumentBuilder(fileName, stream, "\\windows\\fonts\\times.ttf"))
                {
                    using (var dynaDoc = new DynaDoc(docId, UserId, Provider))
                        FillDoc(documentBuilder, "", dynaDoc);
                    FillDoc(documentBuilder, prms);
                }

                return(stream.GetBuffer());
            }
        }
        public Stream Generate(string fileName, IStringParams prms)
        {
            using (var temp = new FileStream(fileName, FileMode.Open))
            {
                using (var wb = new HSSFWorkbook(temp))
                {
                    FillDoc(wb, prms);

                    var stream = new MemoryStream();
                    wb.Write(stream);
                    return(stream);
                }
            }
        }
        public Stream Generate(Doc doc, string fileName, IStringParams prms)
        {
            using (var temp = new FileStream(fileName, FileMode.Open))
            {
                using (var wb = new HSSFWorkbook(temp))
                {
                    using (var dynaDoc = new DynaDoc(doc, UserId, Provider))
                        FillDoc(wb, "", dynaDoc);
                    FillDoc(wb, prms);

                    var stream = new MemoryStream();
                    wb.Write(stream);
                    return(stream);
                }
            }
        }
Example #5
0
        public Stream Generate(string fileName, IStringParams prms)
        {
            var stream = new FileStream(fileName, FileMode.Open);

            try
            {
                using (var documentBuilder = new DocumentBuilder(fileName, stream, "\\windows\\fonts\\times.ttf"))
                {
                    FillDoc(documentBuilder, prms);
                }

                return(stream);
            }
            catch
            {
                stream.Dispose();
                throw;
            }
        }
Example #6
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);
            }
        }
Example #7
0
        public Stream Generate(Doc document, string fileName, IStringParams prms)
        {
            var stream = new MemoryStream();

            try
            {
                using (var documentBuilder = new DocumentBuilder(fileName, stream, "\\windows\\fonts\\times.ttf"))
                {
                    if (document != null)
                    {
                        using (var dynaDoc = new DynaDoc(document, UserId, Provider))
                            FillDoc(documentBuilder, "", dynaDoc);
                    }
                    FillDoc(documentBuilder, prms);
                }

                return(stream);
            }
            catch
            {
                stream.Dispose();
                throw;
            }
        }
Example #8
0
 public Doc InitDocFrom(Doc doc, IStringParams prms)
 {
     return(GetDocRepo(doc).InitDocFrom(doc, prms));
 }
Example #9
0
 public StringParamDataSet(IStringParams stringParams)
 {
     Params = stringParams;
 }
Example #10
0
 public Doc InitDocFrom(Doc doc, IStringParams prms)
 {
     throw new NotImplementedException();
 }