Esempio n. 1
0
        /// <summary>
        /// Puts some data into a worksheet and applies an Excel table style to it.
        /// </summary>
        /// <param name="table">The DataTable</param>
        /// <param name="worksheet">Worksheet object</param>
        /// <param name="tableRow">The starting row number</param>
        /// <param name="tableColumn">The starting column number</param>
        /// <param name="autofitColumns">Automatically size the Excel columns?</param>
        /// <returns></returns>
        private void ImportTable(
            DataTable table,
            Worksheet worksheet,
            int tableRow,
            int tableColumn,
            bool autofitColumns  = true,
            bool applyFormatting = true
            )
        {
            _log.DebugFormat("table row: {0} | table col {1} | dataTableRows {2} | dt name {3}", tableRow, tableColumn, table.Rows.Count, table.TableName);

            //if (_log.IsDebugEnabled)
            //{
            //    foreach (DataRow dataRow in table.Rows)
            //    {
            //        StringBuilder sb = new StringBuilder();
            //        foreach (var item in dataRow.ItemArray)
            //        {
            //            sb.Append(item + " | ");
            //        }
            //        _log.Debug(sb.ToString());
            //    }
            //}

            //padd with 1 for row & col...we can trim it off later...not padding will throw error...
            ExcelUtilities.importTable(
                table,
                table.TableName,
                worksheet,
                tableRow + 1,
                tableColumn + 1,
                autofitColumns,
                false,
                true,
                TableStyleType.TableStyleMedium9,
                false,
                null,
                applyFormatting);
        }