C# Autocomplete textbox using excel as a database?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • collinw
    New Member
    • Feb 2019
    • 2

    C# Autocomplete textbox using excel as a database?

    So I am creating a windows form application that has a autocomplete text box. I want the text box to pull data from an excel spreadsheet. How would I go about doing this? I noticed that you cannot transfer the items from a multideminsiona l into the text box, however, that is the only way I know how to pull the data from excel. Any suggestions?
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    Show your example code, and if you can transfer items from a 'multideminisio nal' (probably you mean multidimensiona l) , you should already have enough knowledge.
    Because 1 row, of 1 columns, is also multidimensiona l.
    Even 1 cell is multidimensiona l, it has a width, and a height.

    Comment

    • Cezar
      New Member
      • Jan 2022
      • 3

      #3
      To read data from Excel worksheet, you'll need to use an Excel library, such as Free Spire.XLS for .NET.

      The following code example shows you how to export data from excel to datatable using it. Then you could traverse the items in the datatable and insert them into your textbox.
      Code:
      //Create a new workbook
      Workbook workbook = new Workbook();       
      //Load excel file
      workbook.LoadFromFile(@”‪C:\Users\Administrator\Desktop\Data.xlsx”);          
      //Get first worksheet
      Worksheet sheet = workbook.Worksheets[0];
      //Export to datatable
      DataTable dataTable = sheet.ExportDataTable();

      Comment

      Working...