Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of a generator.
        /// </summary>
        /// <returns>Generator</returns>
        public ExcelFileGenerator CreateGenerator()
        {
            var sharedStringsInterner = new SharedStringsInterner(_defaultCapacity);
            var styleProvider         = new StyleProvider();

            var visitors = new IDataProviderVisitor[]
            {
                new EnumDataProviderVisitor(),
                new NumericDataProviderVisitor(string.IsNullOrEmpty(_numberFormat)
                    ? (int?)null
                    : styleProvider.GetColumnStyle(_numberFormat)),
                new DateTimeDataProviderVisitor(string.IsNullOrEmpty(_dateFormat)
                    ? (int?)null
                    : styleProvider.GetColumnStyle(_dateFormat)),
                new BooleanDataProviderVisitor(string.IsNullOrEmpty(_booleanFormat)
                    ? (int?)null
                    : styleProvider.GetColumnStyle(_booleanFormat)),
                new DefaultStringDataProviderVisitor(_throwOnLimit)
            };

            var columnFactory = new ExcelColumnFactory(visitors, styleProvider);

            return(new ExcelFileGenerator(columnFactory,
                                          new WorksheetWriter(_encoder, sharedStringsInterner),
                                          new SharedStringsWriter(_encoder, sharedStringsInterner),
                                          new StylesWriter(styleProvider),
                                          _templateStreamFactory(),
                                          _compressionStrategy,
                                          _compressionLevel,
                                          _propertiesFilter));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of a generator.
        /// </summary>
        /// <returns>Generator</returns>
        public ExcelFileGenerator CreateGenerator()
        {
            var sharedStringsInterner = new SharedStringsInterner(_defaultCapacity);
            var styleProvider = new StyleProvider();

            var visitors = new IDataProviderVisitor[]
            {
                new EnumDataProviderVisitor(),
                new NumericDataProviderVisitor(string.IsNullOrEmpty(_numberFormat)
                    ? (int?) null
                    : styleProvider.GetColumnStyle(_numberFormat)),
                new DateTimeDataProviderVisitor(string.IsNullOrEmpty(_dateFormat)
                    ? (int?) null
                    : styleProvider.GetColumnStyle(_dateFormat)),
                new BooleanDataProviderVisitor(string.IsNullOrEmpty(_booleanFormat)
                    ? (int?) null
                    : styleProvider.GetColumnStyle(_booleanFormat)),
                new DefaultStringDataProviderVisitor(_throwOnLimit)
            };

            var columnFactory = new ExcelColumnFactory(visitors, styleProvider);

            return new ExcelFileGenerator(columnFactory,
                new WorksheetWriter(_encoder, sharedStringsInterner),
                new SharedStringsWriter(_encoder, sharedStringsInterner),
                new StylesWriter(styleProvider),
                _templateStreamFactory(),
                _compressionStrategy,
                _compressionLevel,
                _propertiesFilter);
        }