Sort 2 Sheets and update on another Sheet with ole DB
-
private DataTable SortSheet(string FilePath, string SheetName, string SortColumnName,string RankColumn)
{
try
{
var fileName = FilePath;
if (!File.Exists(FilePath))
{
txtLogger.Text += FilePath + " File Not Found!!!" + Environment.NewLine;
MessageBox.Show(" File Not Found!!!");
new DataTable();
}#region Reading excel file // var connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=\\"Excel 12.0;IMEX=1;HDR=NO;TypeGuessRows=0;ImportMixedTypes=Text\\""; ; var connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=\\"Excel 12.0;IMEX=0;HDR=YES;TypeGuessRows=0;ImportMixedTypes=Text\\""; ; DataSet ds = new DataSet(); using (var conn = new OleDbConnection(connectionString)) { try { try { conn.Open(); } catch (Exception ex1) { txtLogger.Text += " exception : " + ex1.StackTrace + Environment.NewLine; MessageBox.Show("File is Open, Please close to proceed!!!"); new DataTable(); } var sheets = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object\[\] { null, null, null, "TABLE" }); DataRow\[\] dr = sheets.Select("\[Table\_name\]= '" + SheetName.ToString() + "$'"); if (dr.Length == 0) { MessageBox.Show("SheetName Not Found!!!"); txtLogger.Text += SheetName.ToString() + " : SheetName Not Found!!!" + Environment.NewLine;
-
private DataTable SortSheet(string FilePath, string SheetName, string SortColumnName,string RankColumn)
{
try
{
var fileName = FilePath;
if (!File.Exists(FilePath))
{
txtLogger.Text += FilePath + " File Not Found!!!" + Environment.NewLine;
MessageBox.Show(" File Not Found!!!");
new DataTable();
}#region Reading excel file // var connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=\\"Excel 12.0;IMEX=1;HDR=NO;TypeGuessRows=0;ImportMixedTypes=Text\\""; ; var connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=\\"Excel 12.0;IMEX=0;HDR=YES;TypeGuessRows=0;ImportMixedTypes=Text\\""; ; DataSet ds = new DataSet(); using (var conn = new OleDbConnection(connectionString)) { try { try { conn.Open(); } catch (Exception ex1) { txtLogger.Text += " exception : " + ex1.StackTrace + Environment.NewLine; MessageBox.Show("File is Open, Please close to proceed!!!"); new DataTable(); } var sheets = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object\[\] { null, null, null, "TABLE" }); DataRow\[\] dr = sheets.Select("\[Table\_name\]= '" + SheetName.ToString() + "$'"); if (dr.Length == 0) { MessageBox.Show("SheetName Not Found!!!"); txtLogger.Text += SheetName.ToString() + " : SheetName Not Found!!!" + Environment.NewLine;
A massive wall of unexplained code is not a question.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
private DataTable SortSheet(string FilePath, string SheetName, string SortColumnName,string RankColumn)
{
try
{
var fileName = FilePath;
if (!File.Exists(FilePath))
{
txtLogger.Text += FilePath + " File Not Found!!!" + Environment.NewLine;
MessageBox.Show(" File Not Found!!!");
new DataTable();
}#region Reading excel file // var connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=\\"Excel 12.0;IMEX=1;HDR=NO;TypeGuessRows=0;ImportMixedTypes=Text\\""; ; var connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=\\"Excel 12.0;IMEX=0;HDR=YES;TypeGuessRows=0;ImportMixedTypes=Text\\""; ; DataSet ds = new DataSet(); using (var conn = new OleDbConnection(connectionString)) { try { try { conn.Open(); } catch (Exception ex1) { txtLogger.Text += " exception : " + ex1.StackTrace + Environment.NewLine; MessageBox.Show("File is Open, Please close to proceed!!!"); new DataTable(); } var sheets = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object\[\] { null, null, null, "TABLE" }); DataRow\[\] dr = sheets.Select("\[Table\_name\]= '" + SheetName.ToString() + "$'"); if (dr.Length == 0) { MessageBox.Show("SheetName Not Found!!!"); txtLogger.Text += SheetName.ToString() + " : SheetName Not Found!!!" + Environment.NewLine;
hi