Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is a method that relies on using Microsoft.Office.Interop.Excel.</p> <p>Please Note: The Excel file I used had only one column with data with 50,000 entries.</p> <p>1) Open the file with Excel, save it as csv, and close Excel.</p> <p>2) Use StreamReader to quickly read the data.</p> <p>3) Split the data on carriage return line feed and add it to a string list.</p> <p>4) Delete the csv file I created.</p> <p>I used System.Diagnostics.StopWatch to time the execution and it took 1.5568 seconds for the function to run.</p> <pre><code>public static List&lt;string&gt; ExcelReader( string fileLocation ) { Microsoft.Office.Interop.Excel.Application excel = new Application(); Microsoft.Office.Interop.Excel.Workbook workBook = excel.Workbooks.Open(fileLocation); workBook.SaveAs( fileLocation + ".csv", Microsoft.Office.Interop.Excel.XlFileFormat.xlCSVWindows ); workBook.Close(true); excel.Quit(); List&lt;string&gt; valueList = null; using (StreamReader sr = new StreamReader(fileLocation + ".csv")) { string content = sr.ReadToEnd(); valueList = new List&lt;string&gt;( content.Split( new string[] {"\r\n"}, StringSplitOptions.RemoveEmptyEntries ) ); } new FileInfo(fileLocation + ".csv").Delete(); return valueList; } </code></pre> <p>Resources:</p> <p><a href="http://www.codeproject.com/Articles/5123/Opening-and-Navigating-Excel-with-C" rel="nofollow noreferrer">http://www.codeproject.com/Articles/5123/Opening-and-Navigating-Excel-with-C</a></p> <p><a href="https://stackoverflow.com/questions/1814562/how-to-split-strings-on-carriage-return-with-c">How to split strings on carriage return with C#?</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload