Please provide more information. VS doesn't do anything with worksheet. Upgrading VS isn't going to change your working code. What delete function are you talking about? If this is related to code then please post that code?
Can not delete a worksheet after upgrading

I upgraded Visual Studio, and the delete function no longer works. I have tried all the formats I have found on the net, but nothing works.
Developer technologies | C#
3 answers
Sort by: Most helpful
-
-
Michael Taylor 60,326 Reputation points
2022-02-09T19:03:16.053+00:00 Updating VS would not impact this code as you're relying on the OpenXML libraries, I believe. Did you happen to upgrade the NuGet packages that contain OpenXML as well?
I do notice that you're actually using 2 different libraries for accessing Excel. You're using the Excel COM interop assemblies directly and also OpenXML. You don't need both so based upon the code it looks like you're using the Excel COM interop in this block of code. While COM hasn't changed, if you used to use a really, really, really old version of VS then there were changes to COM interop but we're talking back in the VS 2005 days.
The following code works for me using the Excel COM interop.
Excel.Application excelApp = null; try { excelApp = new Excel.Application(); var theWorkbook = excelApp.Workbooks.Open(file); if (theWorkbook.Sheets.Count >= 3) { excelApp.DisplayAlerts = false; var worksheet = theWorkbook.Sheets[3]; worksheet.Delete(); excelApp.DisplayAlerts = true; }; theWorkbook.Save(); } finally { excelApp?.Quit(); };
-
Paula Allen 1 Reputation point
2022-06-16T16:59:20.917+00:00 Sorry I have not responded to any of the posts on this subject in a long time as I was in an accident and could not type. I am back now and will review my code, possibly rewriting some of it.