Advertisement
Guest User

Untitled

a guest
May 24th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. if (extension.Trim() == ".xls")
  2. {
  3. // XLS - Excel 2003 and Older
  4. props["Provider"] = "Microsoft.ACE.OLEDB.12.0;";
  5. props["Extended Properties"] = "'Excel 8.0;HDR=Yes;IMEX=3'";
  6. props["Data Source"] = path;
  7. }
  8. else
  9. {
  10. // XLSX - Excel 2007, 2010, 2012, 2013
  11.  
  12. props["Provider"] = "Microsoft.ACE.OLEDB.12.0;";
  13. props["Extended Properties"] = "'Excel 12.0 XML;HDR=No;IMEX=3;'";
  14. props["Data Source"] = path;
  15. }
  16.  
  17. cmd.CommandText = "SELECT TOP 11000 * FROM [" + sheetName + "]";
  18.  
  19. System.Data.DataTable dt = new System.Data.DataTable();
  20. dt.TableName = sheetName;
  21. OleDbDataAdapter da = new OleDbDataAdapter(cmd);
  22.  
  23. da.Fill(dt);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement