Can't import Excel file

Posted by: a.tholle on 29 March 2020, 11:54 pm EST

    • Post Options:
    • Link

    Posted 29 March 2020, 11:54 pm EST

    I’m trying to get started with the spread component in my ASP.NET MVC 5 application. It can load the component easily using this in my view:

    @Html.FpSpread("FpSpread1")
    

    However I cannot for the life of me figure out how to import an Excel file to the spread component. I have used the methods from the documentation like so:

    public ActionResult ExcelView2([FarPoint.Mvc.Spread.MvcSpread]FarPoint.Mvc.Spread.FpSpread FpSpread1)
            {
                ViewBag.Message = "Welcome to GrapeCity";
                FpSpread1 = new FarPoint.Mvc.Spread.FpSpread("FpSpread1", new ControllerContext());
                if (FpSpread1 != null)
                {
                    var value = FpSpread1.ActiveSheetView.Cells[0, 0].Value;
                }
    
                FpSpread1.OpenExcel("PATH/FILENAME.xlsx");
                FarPoint.Web.Spread.DefaultSkins.Office2016White.Apply(FpSpread1);
                FpSpread1.ActiveSheetView.PageSize = FpSpread1.Rows.Count;
                return View(FpSpread1);
            }
    

    It can open the page view and display an excel-like component, but it does not import the data from the excel file. I’ve tried loading an .xls instead of .xlsx, but it’s the same. I have no idea where to go from here or even if my implementation is correct. The documentation only give methods and no indication of how to use them…

  • Posted 30 March 2020, 10:32 pm EST

    Hi,

    To call the ExcelView2 method, we need to make it as Event. Please refer to the attached sample Spread-OpenXLSX.zip and the following code snippet for reference:

    [MvcSpreadEvent("Init", "Spread1")]
            private void ShipmentSpread_Init(object sender, EventArgs e)
            {
                var fpSpread = (FpSpread)sender;
                fpSpread.ActiveSheetView.AllowPage = false;
                fpSpread.Width = Unit.Percentage(100);
                fpSpread.OpenExcel(Server.MapPath("~/Files/FlexGrid.xlsx"));
            }
    

    Regards,

    Manish Gupta

  • Posted 2 April 2020, 7:12 pm EST

    I’ve tried with your sample code, and now it works fine with loading my Excel file. However, it takes a very long time for it to load and it loads without any data, or atleast what I can see. It is so slow, that I cannot get it to change page. Is there a limit to how much data your product can handle?

  • Posted 5 April 2020, 11:34 pm EST

    Hi,

    We are not sure why Excel is loading slowly. Please share the excel file with us with the following information:

    • "* “How the file is generated”

    • “The Spread Version you are using”

    • “Browser”

    • “How much time it took to load the file at your end”

    • “OS information”

      "

    Please share the above information so that we may investigate it at our end.

    Regards,

    Manish Gupta

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels