zhao
2021-06-04 c7ec496f9e41c2227103b3ef776e4a3f91bce6b2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
using System;
using System.Collections.Generic;
using System.Text;
 
using HH.WMS.Utils.NPOI.Util;
 
namespace HH.WMS.Utils.NPOI.HSSF.Record
{
    //Don't remove this class
 
    /// <summary>
    /// 
    /// </summary>
    public class SheetExtRecord:StandardRecord
    {
        short rt = 0;
        short grbitFrt = 0;
        int cb = 0;
        BitField icvPlain = BitFieldFactory.GetInstance(0x7F);
        short optionflag = 0xFF;
        short optionflag2 = 0;
        BitField icvPlain12 = BitFieldFactory.GetInstance(0x7F);
        BitField fCondFmtCalc = BitFieldFactory.GetInstance(0x80);
        BitField fNotPublished = BitFieldFactory.GetInstance(0x100);
        int xclrType = 0;
        int xclrValue = 0;
        long numTint = 0;
 
        public SheetExtRecord()
        {
            rt = 0x0862;
            IsAutoColor = true;
        }
 
        public SheetExtRecord(RecordInputStream in1)
        {
            rt = in1.ReadShort();
            if (rt != 0x0862)
            {
                throw new ArgumentException("frtHeader.rt must be equals 0x0862 in SheetExt record");
            }
            grbitFrt = in1.ReadShort();
            in1.ReadInt();  //reserved
            in1.ReadInt();  //reserved
            cb = in1.ReadInt();
            optionflag = in1.ReadShort();
            in1.ReadShort(); //reserved
            if (cb == 0x28)
            {
                optionflag2 = in1.ReadShort();
                xclrType = in1.ReadInt();
                xclrValue = in1.ReadInt();
                numTint = in1.ReadLong();
                in1.ReadShort();
            }
        }
 
        public short TabColorIndex
        {
            get 
            {
                return icvPlain.GetShortValue(optionflag);
            }
            set
            {
                optionflag=icvPlain.SetShortValue(optionflag,value);
            }
        }
 
        public bool IsAutoColor
        {
            get
            {
                return TabColorIndex == 0x7F;
            }
            set 
            {
                if (value)
                    TabColorIndex = 0x7F;
                else
                    TabColorIndex = 0x08;
            }
        }
 
        public bool EvaluateConditionalFormatting
        {
            get { return fCondFmtCalc.IsSet(optionflag2); }
            set { optionflag2=(short)fCondFmtCalc.SetBoolean(optionflag2,value); }
        }
 
        public bool IsSheetPublished
        {
            get { return !fNotPublished.IsSet(optionflag2); }
            set { optionflag2=(short)fNotPublished.SetBoolean(optionflag2,!value); }
        }
 
        protected override int DataSize
        {
            get 
            {
                return 12 + 4 + 4 + (cb == 0x28? 20 : 0);
            }
        }
        public const short sid=0x862; //2146
 
        public override short Sid
        {
            get { return sid; }
        }
        public override void Serialize(ILittleEndianOutput out1)
        {
            out1.WriteShort(rt);
            out1.WriteShort(grbitFrt);
            out1.WriteInt(0);
            out1.WriteInt(0);
            cb = this.DataSize;
            out1.WriteInt(cb);
            out1.WriteShort(optionflag);
            out1.WriteShort(0);
            if (cb == 0x28)
            {
                out1.WriteShort(optionflag2);
                out1.WriteInt(xclrType);
                out1.WriteInt(xclrValue);
                out1.WriteLong(numTint);
                out1.WriteShort(0); 
            }
        }
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("[SHEETEXT]");
            sb.Append("[/SHEETEXT]");
            return sb.ToString();
        }
        public override object Clone()
        {
            SheetExtRecord rec = new SheetExtRecord();
            rec.rt = rt;
            rec.grbitFrt = grbitFrt;
            rec.cb = this.DataSize;
            rec.optionflag = optionflag;
            if (cb == 0x28)
            {
                rec.optionflag2 = optionflag2;
                rec.xclrType = xclrType;
                rec.xclrValue = xclrValue;
                rec.numTint = numTint;
            }
            return rec;
 
        }
    }
}