title: Reading Excel-file using Oledb - treating content of excel file as Text only
body: <p>I am using C# and OleDb to read data from an excel 2007 file.</p>
  
  <p>Connection string I am using is:</p>
  
  <pre><code>Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES;IMEX=1";
  </code></pre>
  
  <p>Following is the code to read excel: </p>
  
  <pre><code>private OleDbConnection con = null;
  private OleDbCommand cmd = null;
  private OleDbDataReader dr = null;
  private OleDbDataAdapter adap = null;
  private DataTable dt = null;
  private DataSet ds = null;
  private string query;
  private string conStr;
  
  public MainWindow()
  {
      this.InitializeComponent();
      this.query = "SELECT * FROM [Sheet1$]";
      this.conStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\301591\\Desktop\\Fame.xlsx;Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1;TypeGuessRows=0;ImportMixedTypes=Text\"";
  }
  
  private void btnImport_Click(object sender, RoutedEventArgs e)
  {
      this.ImportingDataSetWay();
  }
  
  private void ImportingDataSetWay()
  {
      con = new OleDbConnection(conStr);
      cmd = new OleDbCommand(query, con);
      adap = new OleDbDataAdapter(cmd);
      ds = new DataSet();
      adap.Fill(ds);
      this.grImport.ItemsSource = ds.Tables[0].DefaultView;
  }
  </code></pre>
  
  <p>Here grImport is my WPF Data-Grid and I am using auto-generated columns.</p>
  
  <p>How can I make sure the content stored in Excel will always be read as a string. 
  I am not allowed to modify any of the registry values to achieve this. Is there any better way to read excel. Please guide me. If you need any other information do let me know.</p>
  
  <p>Regards,
  Priyank</p>