0

I am trying to write a script that reads a xls file that the user uploaded on a page. The input looks like this:

<body>
    <form id="uploadForm" runat="server">
        <div>
            <input type="file" id="UpdateFile" runat="server" />
        </div>
        <div>
            <asp:Button runat="server" ID="submitFile" Text="Submit" OnClick="SubmitButton_Click"/>
        </div>
    </form>
    <h3 id="message" runat="server"></h3>
</body>

protected void SubmitButton_Click(object sender, EventArgs e)
{
    if (UpdateFile.PostedFile != null)
    {
        var file = UpdateFile.PostedFile;
        ....

I'm trying to figure out how to read this file line by line. I saw this post suggesting using ExcelPackage but I can't figure out how to add ExcelPackage to my project. I used the NuGet package manager to add ExcelPackage to my project but my code isn't recognizing it, ExcelPackage isn't showing up in my references even though I added it through NuGet.

Community
  • 1
  • 1
Erica Stockwell-Alpert
  • 4,624
  • 10
  • 63
  • 130

2 Answers2

0
DataSet ds= new DataSet();

using (OleDbConnection conn= new OleDbConnection(connStr))
{
 OleDbCommand command = new OleDbCommand(sql, conn);

    conn.Open();
   using (SqlDataAdapter da = new SqlDataAdapter(cmd))
   {
       da.Fill(ds);
   }

}

then you can loop through your dataset:

foreach(DatRow dr in ds.Table[0].Rows)
{


}
Coding Duchess
  • 6,445
  • 20
  • 113
  • 209
0

Add Install-Package EPPlus for this u need Tool----->Library----->package console

Ravi Shah
  • 843
  • 12
  • 29