https://bz.apache.org/bugzilla/show_bug.cgi?id=66198

            Bug ID: 66198
           Summary: Rule M2.4 exception : this error should NEVER happen!
                    If you can provide the triggering file, then please
                    raise a bug at
                    https://bz.apache.org/bugzilla/enter_bug.cgi?product=P
                    OI and attach a file that triggers it, thanks!
           Product: POI
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: XSSF
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

I create a class that inherit from XSSFWorkbook:

public class ExtensionsXSSFWorkbook : NPOI.XSSF.UserModel.XSSFWorkbook
    {
        public ExtensionsXSSFWorkbook() : base() { }
        public ExtensionsXSSFWorkbook ShallowCopy()
        {
            Clear();
            GetCTWorkbook().sheets.sheet.Clear();
            var rel = GetRelations();   
            for(int i = 2; i < rel.Count; i++)
            {
                RemoveRelation(rel[i]);
            }
            ExtensionsXSSFWorkbook currentworkbook =
(ExtensionsXSSFWorkbook)this.MemberwiseClone();
            return currentworkbook; 
        }
    }

I have under class that create instance of this class like this:

            workbooktemplate = new ExtensionsXSSFWorkbook();
            //**************define green style for a cell********************
            green = workbooktemplate.CreateCellStyle();
            green.FillForegroundColor = IndexedColors.Green.Index;
            green.FillPattern = FillPattern.SolidForeground;
            green.Alignment = HorizontalAlignment.Center;
            //**************end of definition********************

            //**************define red style for a cell********************
            red = workbooktemplate.CreateCellStyle();
            red.FillForegroundColor = IndexedColors.Red.Index;
            red.FillPattern = FillPattern.SolidForeground;
            red.Alignment = HorizontalAlignment.Center;
            //**************end of definition********************

            //**************define grey style for a cell********************
            grey = workbooktemplate.CreateCellStyle();
            grey.FillForegroundColor = IndexedColors.Grey25Percent.Index;
            grey.FillPattern = FillPattern.SolidForeground;
            grey.Alignment = HorizontalAlignment.Center;
            //**************end of definition********************

After it create excel document and use the "ShallowCopy" method.
like this:
XSSFWorkbook workbook = workbooktemplate.ShallowCopy();

the error happened only the second time of the use "ShallowCopy" method.
it fail on the RemoveRelation(rel[i]) line.

the fail only happened in the second time because just the I try to delete the
old sheets from the first round.


I sorry that I can't give you the full code but it use inside TPI of my company

I hoped that I gave you enough information to discover the bug.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to