使用下拉列表从Excel电子表格中提取数据

有没有办法,我可以使用Excel电子表格,然后将饲料到我的HTML / C#程序。 我有多达10个dropdownlists(DDL),它们都有不同的值(例如{Ram [8,16,32,64]),另一个是{City [HSV,DAL,SLC,DNV]},硬编码他们在html层中,这些DDL的名字和值代表的是excel电子表格中的数据,我需要编写从电子表格中抽取某些数据的代码,当且仅当在DDL中select了这个特定的值。试图通过尝试让我导入电子表格,并使用它像一个面板里面的电子表格或什么我需要有一种方式,让我补充它更像一个数据库,我需要能够编写函数/像SQL查询一样操作的语句。感谢您花时间阅读本文,并试图帮助我。

HTML

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Find.aspx.cs" Inherits="VirginiaCollege.Find" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Panel ID="Panel1" runat="server" BorderColor="White" BorderStyle="None"> <br /> <br /> <asp:Label ID="Label11" runat="server" Text="Select what type of user you are..."></asp:Label> <br /> <br /> <asp:DropDownList ID="DropDownList1" runat="server"> <asp:ListItem>IT Admin</asp:ListItem> <asp:ListItem>Executive Management</asp:ListItem> <asp:ListItem>Academic Director</asp:ListItem> <asp:ListItem>Teachers</asp:ListItem> <asp:ListItem>Students</asp:ListItem> </asp:DropDownList> <br /> <br /> <asp:Button ID="btSubmitUserType" runat="server" BorderStyle="Ridge" Text="Submit Selection" BackColor="#CCCCCC" OnClick="btSubmitUserType_Click" /> <br /> <br /> </asp:Panel> <asp:Panel ID="Panel6" runat="server" Visible="false" > <asp:Label ID="lblEnterPsWrd" runat="server" Text="Please enter the password"></asp:Label> <br /> <br /> <asp:TextBox ID="tbPassword" runat="server" placeholder="Password" > </asp:TextBox> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:Label ID="Label12" runat="server" Text="Password = Admin"></asp:Label> <br /> <br /> <asp:Button ID="btnSubmitUserTypePsWrd" runat="server" BorderStyle="Ridge" Text="Submit Password" BackColor="#CCCCCC" OnClick="btSubmitUserTypePsWrd_Click" /> </asp:Panel> <asp:Panel ID="Panel7" runat="server" Visible="false" > <asp:Label ID="lblEnterPsWrd2" runat="server" Text="Please enter the password"></asp:Label> <br /> <br /> <asp:TextBox ID="tbPassword2" runat="server" placeholder="Password" ></asp:TextBox> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:Label ID="Label13" runat="server" Text="Password = Director"></asp:Label> <br /> <br /> <asp:Button ID="btnSubmitUserTypePsWrd2" runat="server" BorderStyle="Ridge" Text="Submit Password" BackColor="#CCCCCC" OnClick="btSubmitUserTypePsWrd2_Click" /> </asp:Panel> <asp:Panel ID="Panel8" runat="server" Visible="false" > <asp:Label ID="lblEnterPsWrd3" runat="server" Text="Please enter the password"></asp:Label> <br /> <br /> <asp:TextBox ID="tbPassword3" runat="server" placeholder="Password" ></asp:TextBox> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:Label ID="Label14" runat="server" Text="Password = Student"></asp:Label> <br /> <br /> <asp:Button ID="btnSubmitUserTypePsWrd3" runat="server" BorderStyle="Ridge" Text="Submit Password" BackColor="#CCCCCC" OnClick="btSubmitUserTypePsWrd3_Click" /> </asp:Panel> <asp:Panel ID="Panel2" runat="server" Visible="false"> <asp:CheckBox ID="cbCity" runat="server" Text="City" /> <br /> <asp:CheckBox ID="cbComputerType" runat="server" Text="Computer Type" /> <br /> <asp:CheckBox ID="cbDepartment" runat="server" Text="Department" /> <br /> <asp:CheckBox ID="cbRoomNumber" runat="server" Text="Room Number" /> <br /> <asp:CheckBox ID="cbComputerPosition" runat="server" Text="Computer Postition" /> <br /> <asp:CheckBox ID="cbGraphicsCard" runat="server" Text="Graphics Card" /> <br /> <asp:CheckBox ID="cbRAM" runat="server" Text="RAM" /> <br /> <asp:CheckBox ID="cbProgram" runat="server" Text="Program" /> <br /> <asp:CheckBox ID="cbInstallDate" runat="server" Text="Install Date" /> <br /> <asp:CheckBox ID="cbExperationDate" runat="server" Text="Experation Date" /> <br /> <br /> <br /> <br /> <br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit Search Criteria" /> </asp:Panel> <asp:Panel ID="Panel3" runat="server" Visible="false"> <asp:CheckBox ID="cbComputerType2" runat="server" Text="Computer Type" /> <br /> <asp:CheckBox ID="cbDepartment2" runat="server" Text="Department" /> <br /> <asp:CheckBox ID="cbRoomNumber2" runat="server" Text="Room Number" /> <br /> <asp:CheckBox ID="cbGraphicsCard2" runat="server" Text="Graphics Card" /> <br /> <asp:CheckBox ID="cbRAM2" runat="server" Text="RAM" /> <br /> <asp:CheckBox ID="cbProgram2" runat="server" Text="Program" /> <br /> <br /> <br /> <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Submit Search Criteria" /> </asp:Panel> <asp:Panel ID="Panel4" runat="server" Visible="false"> <asp:CheckBox ID="cbComputerType3" runat="server" Text="Computer Type" /> <br /> <asp:CheckBox ID="cbGraphicsCard3" runat="server" Text="Department" /> <br /> <asp:CheckBox ID="cbRAM3" runat="server" Text="Room Number" /> <br /> <asp:CheckBox ID="cbProgram3" runat="server" Text="Graphics Card" /> <br /> <br /> <asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Submit Search Criteria" /> </asp:Panel> <br /> <br /> <br /> <asp:Panel ID="Panel5" runat="server" Visible="false" HorizontalAlign="Left"> <asp:Label ID="Label1" runat="server" Text="Select City..." Visible="False"></asp:Label> <asp:DropDownList ID="ddlCity" runat="server" Visible="False"> <asp:ListItem>HSV</asp:ListItem> <asp:ListItem>DAL</asp:ListItem> <asp:ListItem></asp:ListItem> </asp:DropDownList> <br /> <asp:Label ID="Label2" runat="server" Text="Select Computer Type" Visible="False"></asp:Label> <asp:DropDownList ID="ddlComputerType" runat="server" Visible="False"> <asp:ListItem>CSTU</asp:ListItem> <asp:ListItem>CAD</asp:ListItem> <asp:ListItem>Staff</asp:ListItem> </asp:DropDownList> <br /> <asp:Label ID="Label3" runat="server" Text="Select Department" Visible="False"></asp:Label> <asp:DropDownList ID="ddlDepartment" runat="server" Visible="False"> <asp:ListItem>3D Imaging</asp:ListItem> <asp:ListItem>Accounting</asp:ListItem> <asp:ListItem>Business</asp:ListItem> <asp:ListItem>Recruiting</asp:ListItem> <asp:ListItem>Management</asp:ListItem> <asp:ListItem>Teaching</asp:ListItem> </asp:DropDownList> <br /> <asp:Label ID="Label4" runat="server" Text="Select Room Number" Visible="False"></asp:Label> <asp:DropDownList ID="ddlRoomNumber" runat="server" Visible="False"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> <asp:ListItem>4</asp:ListItem> <asp:ListItem>5</asp:ListItem> <asp:ListItem>6</asp:ListItem> <asp:ListItem>7</asp:ListItem> <asp:ListItem>8</asp:ListItem> <asp:ListItem>9</asp:ListItem> <asp:ListItem>10</asp:ListItem> <asp:ListItem>11</asp:ListItem> <asp:ListItem>12</asp:ListItem> <asp:ListItem>13</asp:ListItem> <asp:ListItem>14</asp:ListItem> <asp:ListItem>15</asp:ListItem> <asp:ListItem>16</asp:ListItem> <asp:ListItem>17</asp:ListItem> <asp:ListItem>18</asp:ListItem> <asp:ListItem>19</asp:ListItem> <asp:ListItem>20</asp:ListItem> <asp:ListItem>21</asp:ListItem> <asp:ListItem>22</asp:ListItem> <asp:ListItem>23</asp:ListItem> <asp:ListItem>24</asp:ListItem> <asp:ListItem>25</asp:ListItem> <asp:ListItem>26</asp:ListItem> <asp:ListItem>27</asp:ListItem> <asp:ListItem>28</asp:ListItem> <asp:ListItem>29</asp:ListItem> <asp:ListItem>30</asp:ListItem> <asp:ListItem>31</asp:ListItem> <asp:ListItem>32</asp:ListItem> <asp:ListItem>33</asp:ListItem> <asp:ListItem>34</asp:ListItem> <asp:ListItem>35</asp:ListItem> <asp:ListItem>36</asp:ListItem> <asp:ListItem>37</asp:ListItem> <asp:ListItem>38</asp:ListItem> <asp:ListItem></asp:ListItem> </asp:DropDownList> <br /> <asp:Label ID="Label5" runat="server" Text="Select Computer Position" Visible="False"></asp:Label> <asp:DropDownList ID="ddlComputerPosition" runat="server" Visible="False"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> <asp:ListItem>4</asp:ListItem> <asp:ListItem>5</asp:ListItem> <asp:ListItem>6</asp:ListItem> <asp:ListItem>7</asp:ListItem> <asp:ListItem>8</asp:ListItem> <asp:ListItem>9</asp:ListItem> <asp:ListItem>10</asp:ListItem> <asp:ListItem>11</asp:ListItem> <asp:ListItem>12</asp:ListItem> <asp:ListItem>13</asp:ListItem> <asp:ListItem>14</asp:ListItem> <asp:ListItem>15</asp:ListItem> <asp:ListItem>16</asp:ListItem> <asp:ListItem>17</asp:ListItem> <asp:ListItem>18</asp:ListItem> <asp:ListItem>19</asp:ListItem> <asp:ListItem>20</asp:ListItem> <asp:ListItem>21</asp:ListItem> <asp:ListItem>22</asp:ListItem> <asp:ListItem>23</asp:ListItem> <asp:ListItem>24</asp:ListItem> <asp:ListItem>25</asp:ListItem> <asp:ListItem>26</asp:ListItem> <asp:ListItem>27</asp:ListItem> <asp:ListItem>28</asp:ListItem> <asp:ListItem>29</asp:ListItem> <asp:ListItem>30</asp:ListItem> <asp:ListItem>31</asp:ListItem> <asp:ListItem>32</asp:ListItem> <asp:ListItem>33</asp:ListItem> <asp:ListItem>34</asp:ListItem> <asp:ListItem>35</asp:ListItem> <asp:ListItem>36</asp:ListItem> <asp:ListItem>37</asp:ListItem> <asp:ListItem>38</asp:ListItem> <asp:ListItem>39</asp:ListItem> <asp:ListItem>40</asp:ListItem> </asp:DropDownList> <br /> <asp:Label ID="Label6" runat="server" Text="Select Graphics Card" Visible="False"></asp:Label> <asp:DropDownList ID="ddlGraphicsCard" runat="server" Visible="False"> <asp:ListItem>Dell Nvidia Tesla K40 GPU Computing Processor</asp:ListItem> <asp:ListItem>Dell 6 GB Nvidia Tesla K20X GPU Computing Processor</asp:ListItem> <asp:ListItem>Dell 2 GB Nvidia Quadro K620 Graphics Card</asp:ListItem> <asp:ListItem>Nvidia Quadro K6000 SDI I/O</asp:ListItem> <asp:ListItem>VisionTek CryoVenom R9 290</asp:ListItem> <asp:ListItem>Nvidia GeForce GTX 780</asp:ListItem> <asp:ListItem>AMD Radeon R9 295X2</asp:ListItem> <asp:ListItem>AMD Radeon R9 290</asp:ListItem> <asp:ListItem>MSI R9 280X Gaming 3G</asp:ListItem> </asp:DropDownList> <br /> <asp:Label ID="Label7" runat="server" Text="Select RAM" Visible="False"></asp:Label> <asp:DropDownList ID="ddlRAM" runat="server" Visible="False"> <asp:ListItem>8</asp:ListItem> <asp:ListItem>16</asp:ListItem> <asp:ListItem>32</asp:ListItem> <asp:ListItem>64</asp:ListItem> <asp:ListItem>128</asp:ListItem> </asp:DropDownList> <br /> <asp:Label ID="Label8" runat="server" Text="Select Program" Visible="False"></asp:Label> <asp:DropDownList ID="ddlProgram" runat="server" Visible="False"> <asp:ListItem>Xara Photo & Graphic 2013</asp:ListItem> <asp:ListItem>Real-time 3D Character</asp:ListItem> <asp:ListItem>Autodesk Inventor</asp:ListItem> <asp:ListItem>Autodesk AutoCAD 2015</asp:ListItem> <asp:ListItem>Autodesk AutoCAD 2014</asp:ListItem> <asp:ListItem>Autodesk AutoCAD 2013</asp:ListItem> <asp:ListItem>Autodesk AutoCAD 2012</asp:ListItem> <asp:ListItem>Autodesk AutoCAD 2011</asp:ListItem> <asp:ListItem>Autodesk AutoCAD 2010</asp:ListItem> <asp:ListItem>QuickBooks 2017</asp:ListItem> <asp:ListItem>QuickBooks !=2017</asp:ListItem> <asp:ListItem>Visual Studio 2015</asp:ListItem> <asp:ListItem>Visual Studio 2016</asp:ListItem> <asp:ListItem>Visual Studio 2017</asp:ListItem> <asp:ListItem>Visual Studio 2013</asp:ListItem> <asp:ListItem>Visual Studio 2012</asp:ListItem> <asp:ListItem>Visual Studio 2011</asp:ListItem> <asp:ListItem>Visual Studio 2010</asp:ListItem> <asp:ListItem>Visual Studio 2009</asp:ListItem> <asp:ListItem>Visual Studio 2014</asp:ListItem> <asp:ListItem>Office suite</asp:ListItem> </asp:DropDownList> <br /> <asp:Label ID="Label9" runat="server" Text="Select Software Install Date" Visible="False"></asp:Label> <asp:DropDownList ID="ddlSoftInstalDate" runat="server" Visible="False"> <asp:ListItem>JUN 2009</asp:ListItem> <asp:ListItem>MAY 2010</asp:ListItem> <asp:ListItem>JUN 2011</asp:ListItem> <asp:ListItem>DEC 2012</asp:ListItem> <asp:ListItem>DEC 2013</asp:ListItem> <asp:ListItem>JAN 2014</asp:ListItem> <asp:ListItem>JAN 2015</asp:ListItem> <asp:ListItem>FEB 2015</asp:ListItem> <asp:ListItem>JUL 2016</asp:ListItem> </asp:DropDownList> <br /> <asp:Label ID="Label10" runat="server" Text="Select Software Expire Date" Visible="False"></asp:Label> <asp:DropDownList ID="ddlSoftExpDate" runat="server" Visible="False"> <asp:ListItem>DEC 2013</asp:ListItem> <asp:ListItem>DEC 2014</asp:ListItem> <asp:ListItem>MAY 2015</asp:ListItem> <asp:ListItem>DEC 2015</asp:ListItem> <asp:ListItem>JAN 2016</asp:ListItem> <asp:ListItem>JAN 2017</asp:ListItem> <asp:ListItem>NOV 2018</asp:ListItem> <asp:ListItem>DEC 2018</asp:ListItem> <asp:ListItem>DEC 2019</asp:ListItem> </asp:DropDownList> </asp:Panel> <asp:Panel ID="Panel40" runat="server" Visible="False"></asp:Panel> <asp:CheckBoxList ID="CheckBoxList20" runat="server"></asp:CheckBoxList> <asp:Panel ID="Panel50" runat="server" Visible="False"></asp:Panel> </div> </form> </body> </html> 

C#

 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace VirginiaCollege { public partial class Find : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btSubmitUserType_Click(object sender, EventArgs e) { if (DropDownList1.SelectedItem.Text == "IT Admin" ) { Panel6.Visible = true; Panel1.Visible = false; } else if (DropDownList1.SelectedItem.Text == "Executive Management" ) { Panel6.Visible = true; Panel1.Visible = false; } else if (DropDownList1.SelectedItem.Text == "Academic Director") { Panel7.Visible = true; Panel1.Visible = false; } else if (DropDownList1.SelectedItem.Text == "Teachers") { Panel8.Visible = true; Panel1.Visible = false; } else if (DropDownList1.SelectedItem.Text == "Students") { Panel8.Visible = true; Panel1.Visible = false; } } protected void btSubmitUserTypePsWrd_Click(object sender, EventArgs e) { if (tbPassword.Text == "Admin") { Panel2.Visible = true; Panel1.Visible = false; Panel6.Visible = false; } } protected void btSubmitUserTypePsWrd2_Click(object sender, EventArgs e) { if (tbPassword2.Text == "Director") { Panel3.Visible = true; Panel1.Visible = false; Panel7.Visible = false; } } protected void btSubmitUserTypePsWrd3_Click(object sender, EventArgs e) { if (tbPassword3.Text == "Student") { Panel4.Visible = true; Panel1.Visible = false; Panel8.Visible = false; } } protected void Button1_Click(object sender, EventArgs e) { if (cbCity.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label1.Visible = true; DropDownList2.Visible = true; } if (cbComputerType.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label2.Visible = true; DropDownList3.Visible = true; } if (cbDepartment.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label2.Visible = true; DropDownList3.Visible = true; } if (cbRoomNumber.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label3.Visible = true; DropDownList4.Visible = true; } if (cbComputerPosition.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label4.Visible = true; DropDownList5.Visible = true; } if (cbGraphicsCard.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label5.Visible = true; DropDownList6.Visible = true; } if (cbRAM.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label6.Visible = true; DropDownList7.Visible = true; } if (cbProgram.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label7.Visible = true; DropDownList8.Visible = true; } if (cbInstallDate.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label8.Visible = true; DropDownList9.Visible = true; } if (cbExperationDate.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label9.Visible = true; DropDownList10.Visible = true; } } protected void Button2_Click(object sender, EventArgs e) { if (cbComputerType2.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label1.Visible = true; DropDownList2.Visible = true; } if (cbDepartment2.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label2.Visible = true; DropDownList3.Visible = true; } if (cbRoomNumber2.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label3.Visible = true; DropDownList4.Visible = true; } if (cbGraphicsCard2.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label5.Visible = true; DropDownList6.Visible = true; } if (cbRAM2.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label6.Visible = true; DropDownList7.Visible = true; } if (cbProgram2.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label7.Visible = true; DropDownList8.Visible = true; } } protected void Button3_Click(object sender, EventArgs e) { if (cbComputerType3.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label1.Visible = true; DropDownList2.Visible = true; } if (cbGraphicsCard3.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label5.Visible = true; DropDownList6.Visible = true; } if (cbRAM3.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label6.Visible = true; DropDownList7.Visible = true; } if (cbProgram3.Checked == true) { Panel5.Visible = true; Panel2.Visible = false; Label7.Visible = true; DropDownList8.Visible = true; } } protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e) { } } }