Пример #1
0
    }  // end of Main()


    /// <summary>
    /// ParseWrokbooks constructor does all the work.
    /// </summary>
    /// <param name="teamNumberString"></param>
    /// 
    ParseWorkbooks( string teamNumberString )
    {
      int teamNumber = TeamWorkbook.GetTeamNumber( teamNumberString );

      DirectoryInfo topDir = new DirectoryInfo( Environment.CurrentDirectory );  // directory we are in
      string topDirName = topDir.FullName;                                       // full path 
      string teamWorkbookPath = TeamWorkbook.GetTeamPath( topDirName, teamNumberString );  // make the path to our team workbook

      Excel.Application excelApp = new Excel.Application();  // Creates a new Excel Application
      excelApp.Visible = false;                              // Makes Excel invisible to the user.

      TeamWorkbook twb = new TeamWorkbook( excelApp, teamWorkbookPath ); // open our team workbook (must use full path)

      FileInfo[] studentFiles = topDir.GetFiles( "*.xlsx" );   // find all the student assessments
      if ( studentFiles.Length != 0 )
      {
        foreach ( FileInfo fileinf in studentFiles )  // for each student assessment
        {
          StudentWorkbook swb = new StudentWorkbook( excelApp, fileinf.FullName );  // parse the Excel file
          if ( swb.TeamNumber == teamNumber )   // if it's the correct team number
          {
            Console.WriteLine( fileinf.Name );  
            twb.PasteScores( swb.Scores );      // paste scores in the team workbook
            twb.PasteComments( swb.Comments );  // paste comments in teh team workbook
          }
          swb.Close();  // close the student assessment
        }
      }

      twb.Close();                                 // close the team workbook
      excelApp.Application.DisplayAlerts = false;  // no nanny
      excelApp.Quit();                             // close the Excel app

    }  // end of ParseWorkbooks
Пример #2
0
        } // end of Main()

        /// <summary>
        /// ParseWrokbooks constructor does all the work.
        /// </summary>
        /// <param name="teamNumberString"></param>
        ///
        ParseWorkbooks(string teamNumberString)
        {
            int teamNumber = TeamWorkbook.GetTeamNumber(teamNumberString);

            DirectoryInfo topDir           = new DirectoryInfo(Environment.CurrentDirectory);        // directory we are in
            string        topDirName       = topDir.FullName;                                        // full path
            string        teamWorkbookPath = TeamWorkbook.GetTeamPath(topDirName, teamNumberString); // make the path to our team workbook

            Excel.Application excelApp = new Excel.Application();                                    // Creates a new Excel Application
            excelApp.Visible = false;                                                                // Makes Excel invisible to the user.

            TeamWorkbook twb = new TeamWorkbook(excelApp, teamWorkbookPath);                         // open our team workbook (must use full path)

            FileInfo[] studentFiles = topDir.GetFiles("*.xlsx");                                     // find all the student assessments
            if (studentFiles.Length != 0)
            {
                foreach (FileInfo fileinf in studentFiles)                                 // for each student assessment
                {
                    StudentWorkbook swb = new StudentWorkbook(excelApp, fileinf.FullName); // parse the Excel file
                    if (swb.TeamNumber == teamNumber)                                      // if it's the correct team number
                    {
                        Console.WriteLine(fileinf.Name);
                        twb.PasteScores(swb.Scores);     // paste scores in the team workbook
                        twb.PasteComments(swb.Comments); // paste comments in teh team workbook
                    }
                    swb.Close();                         // close the student assessment
                }
            }

            twb.Close();                                // close the team workbook
            excelApp.Application.DisplayAlerts = false; // no nanny
            excelApp.Quit();                            // close the Excel app
        } // end of ParseWorkbooks