title: Excel doc contents to webservice
body: <p>I have a wpf staff creation window in which I can create basic information like first name, last name etc this creates the staff in my REST web service. An example:</p>
  
  <p>Client side:</p>
  
  <pre><code>    private void CreateStaffMember_Click(object sender, RoutedEventArgs e)
      {
          string uri = "http://localhost:8001/Service/Staff";
          StringBuilder sb = new StringBuilder();
          sb.Append("&lt;Staff&gt;");
          sb.AppendLine("&lt;FirstName&gt;" + this.textBox1.Text + "&lt;/FirstName&gt;");
          sb.AppendLine("&lt;LastName&gt;" + this.textBox2.Text + "&lt;/LastName&gt;");
          sb.AppendLine("&lt;Password&gt;" + this.passwordBox1.Password + "&lt;/Password&gt;");
          sb.AppendLine("&lt;/Staff&gt;");
          string NewStudent = sb.ToString();
          byte[] arr = Encoding.UTF8.GetBytes(NewStudent);
          HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
          req.Method = "POST";
          req.ContentType = "application/xml";
          req.ContentLength = arr.Length;
          Stream reqStrm = req.GetRequestStream();
          reqStrm.Write(arr, 0, arr.Length);
          reqStrm.Close();
          HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
          MessageBox.Show("Staff Creation: Status " + resp.StatusDescription);
          reqStrm.Close();
          resp.Close();
      }
  </code></pre>
  
  <p>Web Service side:</p>
  
  <pre><code>    #region POST
  
      [OperationContract]
      [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, UriTemplate = "/Staff")]
      void AddStaff(Staff staff);
  
      #endregion
  
      public void AddStaff(Staff staff)
      {
          staff.StaffID = (++eCount).ToString();
          staff.Salt = GenerateSalt();
          byte[] passwordHash = Hash(staff.Password, staff.Salt);
          staff.Password = Convert.ToBase64String(passwordHash);
          staffmembers.Add(staff);
      }
  </code></pre>
  
  <p>All fine on that side, but Im looking to "import" the staff details from an excel spreadsheet, not sure if import is the correct word but I want to take the first names and last names contained in such n such spreadsheet and add them to the web service from the client side wpf application. </p>
  
  <p>How would I go about it? I have my open file dialog:</p>
  
  <pre><code>    private void Import_Click(object sender, RoutedEventArgs e)
      {
          Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
  
          // Show open file dialog box
          Nullable&lt;bool&gt; result = dlg.ShowDialog();
  
          // Process open file dialog box results
          if (result == true)
          {
              // Open document
              string filename = dlg.FileName;
          }
      }
  </code></pre>
  
  <p>So I open my excel spread sheet then how would I go about taking the inner contents and sending it to the web service? Really stuck on the code or how to go about it :/</p>
  
  <p>Just looking for an automated way of adding staff members rather than manually typing the names, but seeing as the staff excel doc could be named anything I wanted the open file dialog box. The structure inside will always be the same first name then last name. </p>