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
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
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?
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
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
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.
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
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 ?
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)).
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.
why i have to end task excel to open excel file in the second time. Can u have better idea?
I can not use HttpPostedFileBase class. Why ?
For net core, have you a project? .
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
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 ?
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
why u have taken i=3 in for loop
can you helpl me: how open recent in reference manager visual studio 2015
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.
heyy, While Coide in line 33, we are taking Process Error. How to fix this issue ?
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?
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
Even I am also facing the same issue. Please use workbook.close and application.quit.
@@DeepakMalik-pd4ok great, its work, thx =)
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
+HagenMobiler Thanks for your suggestion
If data type datetime. how to import into table in database ? tks
Does it works in visual studio 2019?
Yes, You can use with VS 2019
Okay, I got an error as Hresult efail has been returned from a call to a COM component, can u help me?
When adding the reference I got the above error
Can u please tell. Me the code to directly fetch the data from excel file without uploading it
great leessonn
Getting error at workbook.ActiveSheet.
cannot implicitly convert type 'object' to 'microsoft.office.interop.excel.worksheet'.
I get directory error while using Combine function.. because there is no Server.MapPath in .net core
You can use IWebHostEnvironment to find images in wwwroot
Hello, if I bought this code from you, could I get it today?
Please pay for me as video description. I will share code demo to you.
@@LearningProgramming Ok, money sent!
Thaaaaaaaaaaaaaaaaaaaaaaaaaaaank you Sooooooooooooooooo Much.. You've made my Day..
Sir how to insert excel sheet in sql using entity framwork database first?
i got problem in statement - foreach(var p in ViewBar.ListProduct) ListProduct is not recognized how to solve it?
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.
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
it shows no error, but i can't display my data from the excel worksheet
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
var myFile = System.IO.File.Create(path);
myFile.Close();
stackoverflow.com/questions/17777545/closing-excel-application-process-in-c-sharp-after-data-access - here answer on your question
Need I Office program on my computer?
You don't need install Office on your computer
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 ?
i have the same error, did you fixed ?
www.nuget.org/packages/Microsoft.Office.Interop.Excel/
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)).
It is because Microsoft Excel is not installed on your server may be. Installing Microsoft Excel was helpful for me.
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.
Thank you, Saved me.
You're Welcome
Hi, if i bought you the code it will come with the excel close file ?
Hello, I will share source code demo as video to you.
How I can close the file??, You can see in the video always is open
+Alemaxxx Please explain more detail.
+Alemaxxx Use workbook.Close(); before return View("Success");
+José Carlos Lozano I was trying but that does not work
+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
That does not work
I want to buy this project files
+Abu Muhamad Please pay 5USD to my paypal account is codeprogramminglanguages@gmail.com, I will share code demo to you
+Learning Programming I did, but from another account.
waiting your mail,
Thanks
+Abu Muhamad I shared code demo to you. Please check your gmail. Thanks
Thank you sooooooo much
You're Welcome
thank you coooooool!
Your're Welcome
Grat, tuto :)