Share via

Error in Range class in C# Pivot

Anonymous
2025-02-27T16:55:47+00:00

Hi Team,

Our pivot code working fine with 2402 & older version of excel, but after upgrade we facing issue with below line of codes

((Range)sheet.Range[cell44, Type.Missing].Offset[1, 0]).ShowDetail = true;

cell44 is present on sheet, we are using same dataset but its not working with new excel version.

Also I map object from temp sheet to new sheet & delete temp sheet then try to rename new sheet name its also throw exception in new version but working with old version of excels

ex:  Worksheet resultSheet = null;  Workbook workbook = application_.ActiveWorkbook;  var sheetPivot = BookHelper.AddWorksheet(application_);

            SheetHelper.SetActiveSheet(sheetPivot);

            Range rngDes = sheetPivot.get_Range("A1");

            PivotTable pivotTable = cache.CreatePivotTable(TableDestination: rngDes, TableName: pivotSheetName, DefaultVersion: XlPivotTableVersionList.xlPivotTableVersion10);

            //END Microsoft bug fix - October 2017

            ActiveSheet.PivotTableWizard(Type.Missing, Type.Missing, ActiveSheet.Cells[3, 1], Type.Missing, Type.Missing, Type.Missing, Type.Missing,

                                         Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,

                                         Type.Missing, Type.Missing);

            ((Range)ActiveSheet.Cells[3, 1]).Select();

            ActiveSheet.Name = tempSheetName; ..... logic resultSheet = ActiveSheet;  var tempSheet = (Worksheet)workbook.Sheets[tempSheetName];

            tempSheet.Delete();   resultSheet.Name = newSheetName; // throw error

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2025-02-28T03:22:32+00:00

    From your description, it could be Microsoft changed something at backend.

    For such issue, it will be better to raise it to Microsoft directly.

    Please contact your admin/IT department create a support ticket via Microsoft 365 Admin Center> Support> New service request. Support team there will have the correct channel and resources to help you investigate more and find what exactly the reason has caused this situation.  Get support - Microsoft 365 admin | Microsoft LearnAbout how to find the admin in your organization, you can refer to How do I find my Office 365 admin

    Was this answer helpful?

    0 comments No comments