Esempio n. 1
0
        /// <summary>
        /// Load the data from the <see cref="DataTable"/> starting from the top left cell of the range
        /// </summary>
        /// <param name="table"></param>
        /// <param name="paramsConfig"><see cref="Action{LoacFromCollectionParams}"/> to provide parameters to the function</param>
        /// <example>
        /// <code>
        /// sheet.Cells["C1"].LoadFromDataTable(dataTable, c =>
        /// {
        ///     c.PrintHeaders = true;
        ///     c.TableStyle = TableStyles.Dark1;
        /// });
        /// </code>
        /// </example>
        /// <returns>The filled range</returns>
        public ExcelRangeBase LoadFromDataTable(DataTable table, Action <LoadFromDataTableParams> paramsConfig)
        {
            var parameters = new LoadFromDataTableParams();

            paramsConfig.Invoke(parameters);
            return(LoadFromDataTable(table, parameters.PrintHeaders, parameters.TableStyle));
        }
Esempio n. 2
0
 public LoadFromDataTable(ExcelRangeBase range, DataTable dataTable, LoadFromDataTableParams parameters)
 {
     _range        = range;
     _worksheet    = range.Worksheet;
     _dataTable    = dataTable;
     _printHeaders = parameters.PrintHeaders;
     _tableStyle   = parameters.TableStyle;
 }
Esempio n. 3
0
        /// <summary>
        /// Load the data from the datatable starting from the top left cell of the range
        /// </summary>
        /// <param name="Table">The datatable to load</param>
        /// <param name="PrintHeaders">Print the column caption property (if set) or the columnname property if not, on first row</param>
        /// <param name="TableStyle">The table style to apply to the data</param>
        /// <returns>The filled range</returns>
        public ExcelRangeBase LoadFromDataTable(DataTable Table, bool PrintHeaders, TableStyles TableStyle)
        {
            var parameters = new LoadFromDataTableParams
            {
                PrintHeaders = PrintHeaders,
                TableStyle   = TableStyle
            };
            var func = new LoadFromDataTable(this, Table, parameters);

            return(func.Load());
        }