I am new to Windows Forms, I have a requirement to export a DataTable to excel. I found out that I need to have to Microsoft Office installed on my machine to use Microsoft.Office.Interop.Excel
but I do not have that installed.
I came across EPPLUS. I downloaded and added the reference to the dll in my project. But problem is that it still shows me error.
I used Imports OfficeOpenXml
but this one gives me an error. When I add reference once again, the error disappears and the ExcelPackage
(where I was getting error gets color , same as a any keyword.) But when I build the application or run the application it again gives me the same error.
using (ExcelPackage pck = new ExcelPackage(newFile))
{
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Accounts");
ws.Cells["A1"].LoadFromDataTable(dataTable, true);
pck.Save();
}
Try to change the Target .NET Framework:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.