Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (extension.Trim() == ".xls")
- {
- // XLS - Excel 2003 and Older
- props["Provider"] = "Microsoft.ACE.OLEDB.12.0;";
- props["Extended Properties"] = "'Excel 8.0;HDR=Yes;IMEX=3'";
- props["Data Source"] = path;
- }
- else
- {
- // XLSX - Excel 2007, 2010, 2012, 2013
- props["Provider"] = "Microsoft.ACE.OLEDB.12.0;";
- props["Extended Properties"] = "'Excel 12.0 XML;HDR=No;IMEX=3;'";
- props["Data Source"] = path;
- }
- cmd.CommandText = "SELECT TOP 11000 * FROM [" + sheetName + "]";
- System.Data.DataTable dt = new System.Data.DataTable();
- dt.TableName = sheetName;
- OleDbDataAdapter da = new OleDbDataAdapter(cmd);
- da.Fill(dt);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement