Exemple #1
0
 /// <summary>
 /// Initialize entity enumerator
 /// </summary>
 /// <param name="doc">Excel document</param>
 /// <param name="colCfg">Configuration for entity collection template</param>
 /// <param name="parentRange">Parent range that contains collection</param>
 /// <remarks>
 /// When parentRange is not null, all reference should be related to it.
 /// </remarks>
 public ExcelEntityEnumerator(SpreadsheetDocument doc, CollectionConfigElement colCfg, ExcelOpenXMLRange parentRange = null)
 {
     _doc         = doc;
     _colCfg      = colCfg;
     _parentRange = parentRange;
     Reset();
 }
Exemple #2
0
        /// <summary>
        /// Load data object from file with specific configuration and template
        /// </summary>
        /// <param name="config">Configuration used to define behavior of data loading</param>
        /// <returns></returns>
        IEnumerable <T> IDataParser.Read <T>(TemplateConfigElement config)
        {
            // Go throw template and parse data from excel file
            if (config.Collections == null || config.Collections.Count < 1)
            {
                throw new InvalidOperationException(
                          "No valid collection found in TemplateConfigElement for ExcelParser!");
            }
            // This method only handle one collection
            CollectionConfigElement colCfg = config.Collections[0];
            // Create enumerator for this type of entities
            var parser = new ExcelEntityEnumerable <T>(_doc, colCfg);

            return(parser);
        }
Exemple #3
0
        /// <summary>
        /// Write one object to file with specific configuration and template
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="config">Configuration used to define behavior of data writting</param>
        /// <param name="obj"></param>
        void IDataParser.Write <T>(TemplateConfigElement config, T obj)
        {
            // Go throw template and parse data from excel file
            if (config.Collections == null || config.Collections.Count < 1)
            {
                throw new InvalidOperationException(
                          "No valid collection found in TemplateConfigElement for ExcelParser!");
            }
            // This method only handle one collection
            CollectionConfigElement colCfg = config.Collections[0];
            var writter = new ExcelEntityWriter <T>(_doc, colCfg);

            writter.Write(obj);
            _changed = true;
        }