public static void ExportDataTableToWorksheet(DataTable tb, ImportOpt opt, List <string> formats)
        {
            if (tb == null || opt == null)
            {
                return;
            }

            Excel.Range     topLeft           = opt.topLeft ?? Globals.ThisAddIn.Application.ActiveCell;
            Excel.Worksheet nativeActiveSheet = Globals.ThisAddIn.Application.ActiveSheet as Excel.Worksheet;
            Worksheet       sheet             = Globals.Factory.GetVstoObject(nativeActiveSheet);

            Excel.Range range = topLeft.Resize[tb.Rows.Count + 1, tb.Columns.Count];
            if (opt.overwrite)
            {
                DeleteListObjectInRange(sheet, range);
            }
            if (opt.maxRowsToLoadIntoExcel >= 0)
            {
                RemoveLastNRowsInDataTable(tb, tb.Rows.Count - opt.maxRowsToLoadIntoExcel);
            }

            ListObject list = sheet.Controls.AddListObject(range, GenListObjName(sheet, "DDBTable"));

            list.AutoSetDataBoundColumnHeaders = true;
            list.SetDataBinding(tb);
            list.Disconnect();

            if (formats != null)
            {
                ApplyRangeFormat(list.ListColumns, formats);
            }
        }
        public static void ExportDDBTableToWorksheet(BasicTable tb, ImportOpt opt)
        {
            List <string> format = new List <string>();

            for (int i = 0; i != tb.columns(); i++)
            {
                DATA_TYPE colType = tb.getColumn(i).getDataType();
                format.Add(DDBExcelNumericFormater.GetFormat(colType));
            }
            ExportDataTableToWorksheet(tb.toDataTable(), opt, format);
        }
        public static void ExportDDBTableToWorksheet(DataTable tb, IList <DATA_TYPE> columnsSrcType, ImportOpt opt)
        {
            List <string> format = new List <string>();

            Debug.Assert(columnsSrcType.Count == tb.Columns.Count);

            foreach (var dt in columnsSrcType)
            {
                format.Add(DDBExcelNumericFormater.GetFormat(dt));
            }

            ExportDataTableToWorksheet(tb, opt, format);
        }