Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Sort 2 Sheets and update on another Sheet with ole DB

Sort 2 Sheets and update on another Sheet with ole DB

Scheduled Pinned Locked Moved ASP.NET
databasecomannouncementworkspace
3 Posts 3 Posters 8 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    binumon kb
    wrote on last edited by
    #1

    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;
    
    Richard DeemingR T 2 Replies Last reply
    0
    • B binumon kb

      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;
      
      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      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

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • B binumon kb

        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;
        
        T Offline
        T Offline
        Tony Robbins 2023
        wrote on last edited by
        #3

        hi

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups