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. Excel to import and export data is it the right way?

Excel to import and export data is it the right way?

Scheduled Pinned Locked Moved ASP.NET
sharepointdatabasesecurityxmltutorial
1 Posts 1 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.
  • A Offline
    A Offline
    amina89
    wrote on last edited by
    #1

    Hi, instead of using gridview to insert student marks (I have hundreds of students) thought I used the Excel: 1) allow managers of each module after authentication to download the excel file (containing the students enrolled in the given module), the excel file ted is generated by the following code: Num_inscription note_matière1 -------- ---- note_matière2

    cn.Open();
    SqlDataAdapter da = new SqlDataAdapter(@"DECLARE @MATIERE nvarchar(max)
    SELECT @MATIERE =
    STUFF(
    (
    select distinct ',[' + LIBELLE_MATIERE + ']'
    from MATIERE where CODE_MODULE =11
    for xml path('')
    ),
    1,1,'')

    DECLARE @SQL nvarchar(max)
    SELECT @SQL = N'
    select
    *
    from (

    SELECT ETUDIANT.NUM_INSCRIPTION, ETUDIANT.NOM_PRENOM_ETUDIANT_ARABE,EXAMEN.CODE,
    EXAMEN.NOTE,
    MATIERE.LIBELLE_MATIERE
    FROM ETUDIANT INNER JOIN
    EXAMEN ON ETUDIANT.NUM_INSCRIPTION = EXAMEN.NUM_INSCRIPTION INNER JOIN
    CAPITALISE_MODULE ON
    ETUDIANT.NUM_INSCRIPTION = CAPITALISE_MODULE.NUM_INSCRIPTION INNER JOIN
    MATIERE ON EXAMEN.CODE_MATIERE = MATIERE.CODE_MATIERE INNER JOIN
    MODULE ON CAPITALISE_MODULE.CODE_MODULE = MODULE.CODE_MODULE
    AND MATIERE.CODE_MODULE = MODULE.CODE_MODULE
    WHERE (CAPITALISE_MODULE.CODE_MODULE = 11) AND
    (CAPITALISE_MODULE.CODE_TYPE_RELATION_MODULE = 1)
    ) Data
    PIVOT (
    SUM(NOTE)
    FOR LIBELLE_MATIERE
    IN (
    ' + @MATIERE + '
    )
    ) PivotTable
    '

    exec sp_executesql @SQL

    ", cn);
    DataTable dt = new DataTable();
    da.Fill(dt);
    cn.Close();

       Response.Clear();
       Response.ContentType = "application/vnd.ms-excel";
       string sep = "";
       foreach (DataColumn dc in dt.Columns)
       {
              Response.Write(sep + dc.ColumnName);
              sep = "\\t";
       }
       Response.Write("\\n");
    
       int i;
       foreach (DataRow dr in dt.Rows)
       {
              sep = "";
              for (i = 0; i < dt.Columns.Count; i++)
              {
                     Response.Write(sep + dr\[i\].ToString());
                     sep = "\\t";
              }
              Response.Write("\\n");
       }
    

    }

    }

    But in this code I do not know how to: * Add the following condition: the student'marks is between 0 and 20. * Calculate the average of this module : sum (coeff * mark) / sum (coeff) 2) Allowi

    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