Import Excel Data to ASP.NET MVC

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 69

  • @HagenMobiler
    @HagenMobiler 9 лет назад +1

    I suggest you to use those lines in your code:
    string fileName = Path.GetFileName(excelfile.FileName);
    string path = Path.Combine(Server.MapPath("~/Content"), fileName);
    Just after the line
    if (fileExcel.FileName.EndsWith("xls") || fileExcel.FileName.EndsWith("xlsx")) { (line 28 on your code)
    My suggestion (1st line) gets the real file name, just e.g SpreadSheet.xlxs, not the complete path from client side and then it combines to upload files folder Path in server.
    Thanks for you code, was very helpfull

  • @ozgureren8925
    @ozgureren8925 3 года назад +1

    great leessonn

  • @mohammadaqeel2841
    @mohammadaqeel2841 6 лет назад +1

    Thaaaaaaaaaaaaaaaaaaaaaaaaaaaank you Sooooooooooooooooo Much.. You've made my Day..

  • @gleenababy1731
    @gleenababy1731 4 года назад +1

    Which reference contains the namespace ImportExcelFileInASPNETMVC? I'm facing the error (Please tell me how to get rid of it):-
    Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'ImportExcelFileInASPNETMVC' could not be found (are you missing a using directive or an assembly reference?) WebApplication1 C:\Users\New\Desktop\Kath\WebApplication1\WebApplication1\Controllers\ProductController.cs 8 Active

  • @gennadiigomeniuk5002
    @gennadiigomeniuk5002 6 лет назад

    Can you tell me why the value of row in the "for" loop should be 3? It seems like value of 3 works no matter where the table is placed in the sheet.

  • @MaiLe-ct5rw
    @MaiLe-ct5rw 2 года назад

    why i have to end task excel to open excel file in the second time. Can u have better idea?

  • @anslemopelcastre5980
    @anslemopelcastre5980 5 лет назад +2

    For net core, have you a project? .

  • @cihanbozkurt30
    @cihanbozkurt30 4 года назад

    This structure does not work on the server side. I do not have problems in local. But the server does not add. Could you help ?

  • @khoalam8017
    @khoalam8017 8 лет назад +2

    can you helpl me: how open recent in reference manager visual studio 2015

  • @hienpham6974
    @hienpham6974 8 лет назад +2

    I go through all your video and at the end when i import an Excel file the program breaks at System.IO.File.Delete(path); . Can you solve this problem?

    • @haifao8569
      @haifao8569 8 лет назад

      I faced the same problem.. open the task manager you will see the excel file in processes chose it and click on end task, I think we should close it from the program

    • @DeepakMalik-pd4ok
      @DeepakMalik-pd4ok 5 лет назад +2

      Even I am also facing the same issue. Please use workbook.close and application.quit.

    • @victorjara7438
      @victorjara7438 3 года назад

      @@DeepakMalik-pd4ok great, its work, thx =)

  • @mihaiflorianenache4110
    @mihaiflorianenache4110 2 года назад

    I can not use HttpPostedFileBase class. Why ?

  • @quockyla8415
    @quockyla8415 3 года назад

    i have a problem, but with property of database Type is Date or Datetime, how to convert, i try Convert.ToDateTime() and DateTime.Parse() but i not work. pls rep me

  • @diogofagundes5622
    @diogofagundes5622 6 лет назад

    Thank you, Saved me.

  • @frknbltci
    @frknbltci 4 года назад

    heyy, While Coide in line 33, we are taking Process Error. How to fix this issue ?

  • @RafayKhanfy
    @RafayKhanfy 7 лет назад

    Getting error at workbook.ActiveSheet.
    cannot implicitly convert type 'object' to 'microsoft.office.interop.excel.worksheet'.

  • @parisasaeedi8674
    @parisasaeedi8674 6 лет назад +1

    Thank you sooooooo much

  • @AlemaxM
    @AlemaxM 9 лет назад +1

    I open the file and read it, but the problem is when i see the task manager there is excel process like your video when you close two process , who i can close it?, I think that you are not closing the excel file , but I don't have idea how to close it. Can you understand me?. Nice video :). Greetings

    • @Nechytailo
      @Nechytailo 6 лет назад

      var myFile = System.IO.File.Create(path);
      myFile.Close();

    • @zhoodarkasymov1774
      @zhoodarkasymov1774 6 лет назад

      stackoverflow.com/questions/17777545/closing-excel-application-process-in-c-sharp-after-data-access - here answer on your question

  • @memansoorimtiaz
    @memansoorimtiaz 8 лет назад

    Sir how to insert excel sheet in sql using entity framwork database first?

  • @Gregopaok4
    @Gregopaok4 6 лет назад

    i got problem in statement - foreach(var p in ViewBar.ListProduct) ListProduct is not recognized how to solve it?

    • @michaelchandra9100
      @michaelchandra9100 6 лет назад

      Perhaps because ListProduct is a variable which given from Controller for throwing it to View. You need to define the ListProduct first so it shouldnt be empty.

  • @AnuRadha-wb7ev
    @AnuRadha-wb7ev 5 лет назад

    Can u please tell. Me the code to directly fetch the data from excel file without uploading it

  • @atiqahazizee1592
    @atiqahazizee1592 5 лет назад

    it shows no error, but i can't display my data from the excel worksheet

  • @tainguyen7495
    @tainguyen7495 7 лет назад

    If data type datetime. how to import into table in database ? tks

  • @hungerfreenation1691
    @hungerfreenation1691 4 года назад

    I get directory error while using Combine function.. because there is no Server.MapPath in .net core

  • @gauravnautiyal2925
    @gauravnautiyal2925 3 года назад

    why u have taken i=3 in for loop

  • @vinayakjambhale5985
    @vinayakjambhale5985 5 лет назад

    Hello sir, Thanks for this code, but i got an error on line - Excel.Application application = new Excel.Application();
    Error description - Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
    I have already done with giving permissions to IUSR IISUSER & all stuff.

  • @alejandroelizondogonzalez9802
    @alejandroelizondogonzalez9802 5 лет назад +1

    Hello, if I bought this code from you, could I get it today?

  • @nestormatias217
    @nestormatias217 7 лет назад

    works it local but in server error
    Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

    • @sunmbalsiddiqui9717
      @sunmbalsiddiqui9717 7 лет назад

      It is because Microsoft Excel is not installed on your server may be. Installing Microsoft Excel was helpful for me.

  • @vikasgowda351
    @vikasgowda351 3 года назад

    Can I get a code to delete a column present in excel sheet using asp. Net. I will pay you money for the working code

  • @MDMizanurRahman89
    @MDMizanurRahman89 6 лет назад

    thank you coooooool!

  • @hajamainudeen5396
    @hajamainudeen5396 4 года назад

    Does it works in visual studio 2019?

    • @LearningProgramming
      @LearningProgramming  4 года назад

      Yes, You can use with VS 2019

    • @hajamainudeen5396
      @hajamainudeen5396 4 года назад

      Okay, I got an error as Hresult efail has been returned from a call to a COM component, can u help me?

    • @hajamainudeen5396
      @hajamainudeen5396 4 года назад

      When adding the reference I got the above error

  • @faruksengul5813
    @faruksengul5813 7 лет назад

    I could not refer to Excel.
    I downloaded nuget.But did not work. Error =" The COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' could not be assigned to the interface 'Microsoft.Office.Interop.Excel._Application'. '{000208D5-0000-0000-C000-000000000046}' This operation failed because the QueryInterface call in the COM component for the interface with the IID failed with the following error: The library has not been registered. (HRESULT returned exception: 0x8002801D (TYPE_E_LIBNOTREGISTERED))." Can you help plaese ?

  • @aaronaaronaaron5922
    @aaronaaronaaron5922 6 лет назад

    Grat, tuto :)

  • @ThunderwavePL
    @ThunderwavePL 8 лет назад

    Need I Office program on my computer?

  • @fernandorochaolivera2404
    @fernandorochaolivera2404 5 лет назад

    Hi, if i bought you the code it will come with the excel close file ?

  • @AlemaxM
    @AlemaxM 9 лет назад

    How I can close the file??, You can see in the video always is open

    • @LearningProgramming
      @LearningProgramming  9 лет назад

      +Alemaxxx Please explain more detail.

    • @jclp5
      @jclp5 9 лет назад +1

      +Alemaxxx Use workbook.Close(); before return View("Success");

    • @AlemaxM
      @AlemaxM 9 лет назад

      +José Carlos Lozano I was trying but that does not work

    • @jclp5
      @jclp5 9 лет назад

      +Alemaxxx
      if (excelfile.FileName.EndsWith("xls") || excelfile.FileName.EndsWith("xlsx"))
      {
      string fileName = Path.GetFileName(excelfile.FileName);
      string path = Path.Combine(Server.MapPath("~/Content"), fileName);
      if (System.IO.File.Exists(path))
      System.IO.File.Delete(path);
      excelfile.SaveAs(path);
      //Read data from excel file
      Excel.Application application = new Excel.Application();
      Excel.Workbook workbook = application.Workbooks.Open(path);
      Excel.Worksheet worksheet = workbook.ActiveSheet;
      Excel.Range range = worksheet.UsedRange;
      List listProducts = new List();
      for (int row = 3; row

    • @AlemaxM
      @AlemaxM 8 лет назад +1

      That does not work

  • @freesyriancam
    @freesyriancam 8 лет назад

    I want to buy this project files

    • @LearningProgramming
      @LearningProgramming  8 лет назад

      +Abu Muhamad Please pay 5USD to my paypal account is codeprogramminglanguages@gmail.com, I will share code demo to you

    • @freesyriancam
      @freesyriancam 8 лет назад

      +Learning Programming I did, but from another account.
      waiting your mail,
      Thanks

    • @LearningProgramming
      @LearningProgramming  8 лет назад

      +Abu Muhamad I shared code demo to you. Please check your gmail. Thanks