/**
         * Creates a StyleRecord object
         * @param id        the number of the style record to Create (meaning its position in
         *                  a file as MS Excel would Create it.
         * @return record containing a StyleRecord
         * @see org.apache.poi.hssf.record.StyleRecord
         * @see org.apache.poi.hssf.record.Record
         */

        private static Record CreateStyle(int id)
        {   // we'll need multiple editions
            StyleRecord retval = new StyleRecord();

            switch (id)
            {

                case 0:
                    retval.XFIndex = (unchecked((short)0xffff8010));
                    retval.SetBuiltinStyle(3);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;

                case 1:
                    retval.XFIndex = (unchecked((short)0xffff8011));
                    retval.SetBuiltinStyle(6);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;

                case 2:
                    retval.XFIndex = (unchecked((short)0xffff8012));
                    retval.SetBuiltinStyle(4);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;

                case 3:
                    retval.XFIndex = (unchecked((short)0xffff8013));
                    retval.SetBuiltinStyle(7);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;

                case 4:
                    retval.XFIndex = (unchecked((short)0xffff8000));
                    retval.SetBuiltinStyle(0);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;

                case 5:
                    retval.XFIndex = (unchecked((short)0xffff8014));
                    retval.SetBuiltinStyle(5);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;
            }
            return retval;
        }
    /**
 * Creates a new StyleRecord, for the given Extended
 *  Format index, and adds it onto the end of the
 *  records collection
 */
    public StyleRecord CreateStyleRecord(int xfIndex) {
        // Style records always follow after 
        //  the ExtendedFormat records
        StyleRecord newSR = new StyleRecord();
        newSR.XFIndex = (short)xfIndex;
        
        // Find the spot
        int addAt = -1;
        for(int i=records.Xfpos; i<records.Count &&
                addAt == -1; i++) {
            Record r = records[i];
            if(r is ExtendedFormatRecord ||
                    r is StyleRecord) {
                // Keep going
            } else {
                addAt = i;
            }
        }
        if(addAt == -1) {
            throw new InvalidOperationException("No XF Records found!");
        }
        records.Add(addAt, newSR);
        
        return newSR;
  }