public override void ExecuteCommand(CancellationToken token) { var file = DialogManager.ShowSelectFileDialog(); if (file == null) { return; } var ok = new Action <string>((tableName) => { ExcelImporter importer = new ExcelImporter(); DDLManager ddlManager = new DDLManager(); var meta = importer.GetMetaData(file.FullName); ddlManager.CreateTable(tableName, meta); importer.ImportToTable(file.FullName, tableName, meta); ShellManager.AppendToEndOfSelection("SELECT * FROM " + tableName); ShellManager.AppendToEndOfSelection("--DROP TABLE " + tableName); }); DialogManager.GetDialogInputFromUser("Choose target table name (This table will be created)", "ExcelImport", ok); }
public override void ExecuteCommand(CancellationToken token) { var file = DialogManager.ShowSelectFileDialog(); if (file == null) { return; } var ddlManager = new DDLManager(); var bulkdInsertManager = new BulkInsertManager(); String connString = ConnectionManager.GetConnectionStringForCurrentWindow(); Console.WriteLine("Start time" + DateTime.Now); ExcelStreamReader.Execute(file.FullName, reader => reader.ForEachSheet(sheet => { var schema = sheet.GetSchema(); ddlManager.CreateTable(schema.TableName, schema, connString); bulkdInsertManager.BulkInsertTo(schema, schema.TableName, sheet, connString); }) ); }