title: Open .xls/.xlsx file through web browser and make it editable for the user
body: <p><strong>Specification</strong></p>
  
  <ul>
  <li>using .Net 3.5/4.0 framework</li>
  <li>Web Application C#</li>
  <li>Machine don't have MS Office install</li>
  </ul>
  
  <p><strong>Problem:</strong>
   Need to open excel file report from web browser for the user to edit the report and save the update on the excel file. (is it possible? for the fact that the machine don't have a MS office install). </p>
  
  <p><strong>By Code:</strong> I can only read the file and display it through grid but cannot edit.</p>
  
  <pre><code>public void LoadExceltotheGrid()
  {
      string connectionString = "";
      string fileLocation = MapPath("FileMe20140107.xlsx");
      string fileExtension = Path.GetExtension(fileLocation);
      if (fileExtension == ".xls")
      {
          connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
          fileLocation + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
      }
      else if (fileExtension == ".xlsx")
      {
          connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
          fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
      }
      System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection(connectionString);
      System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand();
      cmd.CommandType = System.Data.CommandType.Text;
      cmd.Connection = con;
      System.Data.OleDb.OleDbDataAdapter dAdapter = new System.Data.OleDb.OleDbDataAdapter(cmd);
      DataTable dtExcelRecords = new DataTable();
      con.Open();
      DataTable dtExcelSheetName = con.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null);
      string getExcelSheetName = dtExcelSheetName.Rows[0]["Table_Name"].ToString();
      cmd.CommandText = "SELECT * FROM [" + getExcelSheetName + "]";
      dAdapter.SelectCommand = cmd;
      dAdapter.Fill(dtExcelRecords);
      GridView1.DataSource = dtExcelRecords;
      GridView1.DataBind();
  }
  </code></pre>