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. General Programming
  3. C#
  4. Total Dynamic Report.

Total Dynamic Report.

Scheduled Pinned Locked Moved C#
phpcomquestion
5 Posts 3 Posters 0 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.
  • D Offline
    D Offline
    Dot Net Jantu
    wrote on last edited by
    #1

    Hi All, I am back for eating everybodies head. Attached is the excel file in which there are 3 formats of a same table in a report. So based upon these 3 formats I have created 3 different rpt files. Now the client is saying that he can anytime add any number of columns in any place and report should be generated. This means right now if you have look at the excel file, Format 2 has the highest number of column. But he can introduce fields in between or in the beginning or in the end. Right now "Reading Before Adjustment" or "Reading After Adjustment" has 3 columns, but number of columns can either increase or decrease also. So is it possible to dynamically create text object, assign them locations on the report and so on? I did not find the facility of attachment. You can see the attachment here : Here[^]

    Thanks and Regards,

    S 1 Reply Last reply
    0
    • D Dot Net Jantu

      Hi All, I am back for eating everybodies head. Attached is the excel file in which there are 3 formats of a same table in a report. So based upon these 3 formats I have created 3 different rpt files. Now the client is saying that he can anytime add any number of columns in any place and report should be generated. This means right now if you have look at the excel file, Format 2 has the highest number of column. But he can introduce fields in between or in the beginning or in the end. Right now "Reading Before Adjustment" or "Reading After Adjustment" has 3 columns, but number of columns can either increase or decrease also. So is it possible to dynamically create text object, assign them locations on the report and so on? I did not find the facility of attachment. You can see the attachment here : Here[^]

      Thanks and Regards,

      S Offline
      S Offline
      SungBae Han
      wrote on last edited by
      #2

      you can read excel sheet in c# from first cell to end cell... and you will be insert into generic list from your data. then you can sorting and searching... show under code... it's connect excel ole connect -----------------

          DataTable dtTempTable = new DataTable();
          DataTable dtMyTable = new DataTable();
          DataRow drMyRow;
          int nRowCount = 0;
      
          nRowCount = 0;
      
          strSCell\[0\] = "A";
          strSCell\[1\] = "1";
          strECell\[0\] = "IV";
          strECell\[1\] = "65536";
      
          if (CommonLib.IsNullString(FileName.Substring(FileName.Length - 4, 4)).Equals("xlsx"))
          {
              // strProvider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + (FilePath + FileName) + ";Extended Properties=Excel 12.0;IMEX=1;HDR=Yes;";
      
              strProvider = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=";
              strProvider += (FilePath + FileName);
              strProvider += @";Extended Properties=""Excel 12.0;Imex=1;HDR=YES;""";
      
              strQuery = "Select \* From \[Sheet1$" + strSCell\[0\] + strSCell\[1\] + ":" + strECell\[0\] + strECell\[1\] + "\]";
          }
          else
          {
              // strProvider = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + (FilePath + FileName) + ";Extended Properties=Excel 8.0;IMEX=1;HDR=Yes;";
      
              strProvider = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
              strProvider += (FilePath + FileName);
              strProvider += @";Extended Properties=""Excel 8.0;Imex=1;HDR=YES;""";
      
              strQuery = "Select \* From \[Sheet1$" + strSCell\[0\] + strSCell\[1\] + ":" + strECell\[0\] + strECell\[1\] + "\]";
          }
      
          OLEDBConnection = new OleDbConnection(strProvider);
          OLECommandObject = new OleDbCommand(strQuery, OLEDBConnection);
          OLEDBConnection.Open();
      
          if (OLEReader != null)
          {
              if (!OLEReader.IsClosed)
                  OLEReader.Close();
          }
      
          OLEReader = OLECommandObject.ExecuteReader(CommandBehavior.CloseConnection);
          dtTempTable.Load(OLEReader);
      
          if (dtTempTable.Rows.Count > 0)
          {
              dtMyTable = dtTempTable.Copy();
          }
      
          if (OLEReader != null)
          {
              if (!OLEReader.IsClosed)
                  OLEReader.Close();
              OLEReader.Dispose();
          }
      
          if (OLEDBConnection != null)
              OLEDBConnection.Close();
      
          return dtMyTable;
      

      modified on

      L 1 Reply Last reply
      0
      • S SungBae Han

        you can read excel sheet in c# from first cell to end cell... and you will be insert into generic list from your data. then you can sorting and searching... show under code... it's connect excel ole connect -----------------

            DataTable dtTempTable = new DataTable();
            DataTable dtMyTable = new DataTable();
            DataRow drMyRow;
            int nRowCount = 0;
        
            nRowCount = 0;
        
            strSCell\[0\] = "A";
            strSCell\[1\] = "1";
            strECell\[0\] = "IV";
            strECell\[1\] = "65536";
        
            if (CommonLib.IsNullString(FileName.Substring(FileName.Length - 4, 4)).Equals("xlsx"))
            {
                // strProvider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + (FilePath + FileName) + ";Extended Properties=Excel 12.0;IMEX=1;HDR=Yes;";
        
                strProvider = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=";
                strProvider += (FilePath + FileName);
                strProvider += @";Extended Properties=""Excel 12.0;Imex=1;HDR=YES;""";
        
                strQuery = "Select \* From \[Sheet1$" + strSCell\[0\] + strSCell\[1\] + ":" + strECell\[0\] + strECell\[1\] + "\]";
            }
            else
            {
                // strProvider = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + (FilePath + FileName) + ";Extended Properties=Excel 8.0;IMEX=1;HDR=Yes;";
        
                strProvider = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
                strProvider += (FilePath + FileName);
                strProvider += @";Extended Properties=""Excel 8.0;Imex=1;HDR=YES;""";
        
                strQuery = "Select \* From \[Sheet1$" + strSCell\[0\] + strSCell\[1\] + ":" + strECell\[0\] + strECell\[1\] + "\]";
            }
        
            OLEDBConnection = new OleDbConnection(strProvider);
            OLECommandObject = new OleDbCommand(strQuery, OLEDBConnection);
            OLEDBConnection.Open();
        
            if (OLEReader != null)
            {
                if (!OLEReader.IsClosed)
                    OLEReader.Close();
            }
        
            OLEReader = OLECommandObject.ExecuteReader(CommandBehavior.CloseConnection);
            dtTempTable.Load(OLEReader);
        
            if (dtTempTable.Rows.Count > 0)
            {
                dtMyTable = dtTempTable.Copy();
            }
        
            if (OLEReader != null)
            {
                if (!OLEReader.IsClosed)
                    OLEReader.Close();
                OLEReader.Dispose();
            }
        
            if (OLEDBConnection != null)
                OLEDBConnection.Close();
        
            return dtMyTable;
        

        modified on

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Please use the code block button to insert <pre></pre> tags around your code to make it readable. Check the posting guidelines at the top of this forum.

        I must get a clever new signature for 2011.

        S 1 Reply Last reply
        0
        • L Lost User

          Please use the code block button to insert <pre></pre> tags around your code to make it readable. Check the posting guidelines at the top of this forum.

          I must get a clever new signature for 2011.

          S Offline
          S Offline
          SungBae Han
          wrote on last edited by
          #4

          Modify my reply. thanks for your kind.

          L 1 Reply Last reply
          0
          • S SungBae Han

            Modify my reply. thanks for your kind.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            No problem, I'm glad you have joined the list of people who contribute to the site. Have fun :-D

            I must get a clever new signature for 2011.

            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