C# trying to import an older project, which relies on .office.interop.excel RRS feed

  • Question

  • Hello everyone,

    around 1-2years ago i wrote a small programm which uses the Microsoft.Office.Interop.Excel to auto create multiple reports from a set of data.

    Now i'm using a new Laptop, new VS version, but when i open my old project i get a tonne of "red" lines in my code after i readded the nuget package for excel (Somehow on my old PC it doesn't even show the Nuget Package for excel and im not sure i needed to add it to use Microsoft.Office...).

    The things which are not working correctly are:

    Writing a string into a cell:

    oldcode: myworksheet.Cells[x][y] = "mystring"

    Is this the same now as myworksheet.Cells[x,y] = "mystring" ?

    Selecting a Chart:

    old code: Chartobject chart = mysheet.ChartObjects("DiagrammName");

    Would Chartobject chart = mysheet.ChartObjects("DiagrammName") as Chartobject; work without issue?

    Writing string into a charts SeriesCollection:

    old code: chart.Chart.SeriesCollection(1).Values = "my string which should still work"

    Here the reference for ".Values" doesnt seem to exist anymore and i dont know how to substitute it.

    For the reports i'm using a premade master .xls file which is just filled up with data.

    Did anyone ever have a similar problem? I havent really touched the code in a while and even though the .exe still works fine it would help if i could modify the code in the future, without completely rewritin everything. :)

    Greetings from germany.

    Monday, November 25, 2019 2:38 PM