Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. public static DataSet FirstColumn(string filename)
  2. {
  3.  
  4. string filepath = filename;
  5.  
  6. string sheetName = "First";
  7. //Oledb connection to generate excel in temporary folder on server
  8. string connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + filepath + "';Extended Properties="Excel 12.0 Xml;HDR=YES;"";
  9. using (OleDbConnection conn = new OleDbConnection(connectionstring))
  10. {
  11. conn.Open();
  12. OleDbDataAdapter objDA = new System.Data.OleDb.OleDbDataAdapter
  13. ("select * from [" + sheetName + "$]", conn);
  14. DataSet excelDataSet = new DataSet();
  15. objDA.Fill(excelDataSet);
  16. return excelDataSet;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement