Author Topic: Add Excel 16.0 Object Library  (Read 1192 times)

Sparkysliderz

  • Newbie
  • *
  • Posts: 4
    • View Profile
Add Excel 16.0 Object Library
« on: September 08, 2022, 08:53:10 AM »
Hi everyone,

Visual studio 2022 (64-Bit) V17.3.3 & AdvancedHMIv399yBeta38.

I'm completely stumped now.

I have written a windows application that extracts and displays a count value so the manager can insert comments next to the count value, the count, the time of the count and the comment are added to a DataGridView at the press of a "confirm" button. This part is working correctly and is not a problem.

my next step would be to load the data from the DataGridView into an Excel spreadsheet then continue to run my application for a different production line count.

My problem is I cannot get "Project -> Add Reference -> COM -> Microsoft Excel 16.0 Object Library" to install.
I get the pop up message "A reference to 'Microsoft Excel 16.0 Object Library' could not be added. This is not a COM component"

If i start with a new project (without AdvancedHMI) I can install the Excel library with no problem but then i cannot open the AdvancedHMIv335.sln to rewrite my application.

I know I am probably stupid but I just dont know a great deal about Visual Studio but i am in desperate need of help as i am completely stuck now so near to completing my application.

Thanks for reading, Shaun.
 

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Add Excel 16.0 Object Library
« Reply #1 on: September 08, 2022, 09:22:06 AM »
It's been a while since I have used the Excel COM object, but it does require Excel to be installed in the PC you are opening the project on.

I prefer to use a library that does not require Excel. I used to use EPPlus until they added a requirement for an expensive license fee. I have recently been testing ClosedXML which can be added to a project using the Nuget Manager.

Sparkysliderz

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Add Excel 16.0 Object Library
« Reply #2 on: September 08, 2022, 09:36:14 AM »
Hi Archie, thanks for the prompt reply.

I do have MS office installed Home office & business 2019.

 ClosedXML which can be added to a project using the "Nuget Manager"?

is it possible to import AdvancedHMI into an existing project? maybe if i set up excel first then import AdvancedHMI i only have to re-write my application?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Add Excel 16.0 Object Library
« Reply #3 on: September 08, 2022, 10:47:34 AM »
If you go to Project->Manage Nuget Packages..
Select Browse
In the search box enter "Excel"
You can then select ClosedXML

A very simple snippet of code:
Code: [Select]
        Dim WB As New ClosedXML.Excel.XLWorkbook(".\ExcelFile.xlsx")
        Me.Text = WB.Worksheets(0).Cell("A1").Value

It is much easier to import your existing program into AdvancedHMI because of all the references and links in the AdvancedHMI solution.

Sparkysliderz

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Add Excel 16.0 Object Library
« Reply #4 on: September 09, 2022, 02:55:18 AM »
Hi Archie,
its easy when you know how  ;D

Thanks for the help, i found several different packages there I will try them to see which one is the best "fit" for me.

Thanks again my friend  ;D

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Add Excel 16.0 Object Library
« Reply #5 on: September 09, 2022, 08:52:57 AM »
It's been a while since I have used the Excel COM object, but it does require Excel to be installed in the PC you are opening the project on.

I prefer to use a library that does not require Excel. I used to use EPPlus until they added a requirement for an expensive license fee. I have recently been testing ClosedXML which can be added to a project using the Nuget Manager.

You can use EPPlus 4.5.3.3  Their last 'free' version if I am not mistaken.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================