示例#1
0
        private static CellCollection PopulateCells(List <Record> records, SharedResource sharedResource)
        {
            CellCollection cells = new CellCollection();

            cells.SharedResource = sharedResource;
            foreach (Record record in records)
            {
                record.Decode();
                switch (record.Type)
                {
                //case RecordType.DIMENSIONS:
                //    DIMENSIONS dimensions = record as DIMENSIONS;
                //    cells.FirstRowIndex = dimensions.FirstRow;
                //    cells.FirstColIndex = dimensions.FirstColumn;
                //    cells.LastRowIndex = dimensions.LastRow-1;
                //    cells.LastColIndex = dimensions.LastColumn-1;
                //    break;
                case RecordType.BOOLERR:
                    BOOLERR boolerr = record as BOOLERR;
                    cells.CreateCell(boolerr.RowIndex, boolerr.ColIndex, boolerr.GetValue(), boolerr.XFIndex);
                    break;

                case RecordType.LABELSST:
                    LABELSST label = record as LABELSST;
                    Cell     cell  = cells.CreateCell(label.RowIndex, label.ColIndex, sharedResource.GetStringFromSST(label.SSTIndex), label.XFIndex);
                    cell.Style.RichTextFormat = sharedResource.SharedStringTable.RichTextFormatting[label.SSTIndex];
                    break;

                case RecordType.NUMBER:
                    NUMBER number = record as NUMBER;
                    cells.CreateCell(number.RowIndex, number.ColIndex, number.Value, number.XFIndex);
                    break;

                case RecordType.RK:
                    RK rk = record as RK;
                    cells.CreateCell(rk.RowIndex, rk.ColIndex, Record.DecodeRK(rk.Value), rk.XFIndex);
                    break;

                case RecordType.MULRK:
                    MULRK mulrk = record as MULRK;
                    int   row   = mulrk.RowIndex;
                    for (int col = mulrk.FirstColIndex; col <= mulrk.LastColIndex; col++)
                    {
                        int    index   = col - mulrk.FirstColIndex;
                        object value   = Record.DecodeRK(mulrk.RKList[index]);
                        int    XFindex = mulrk.XFList[index];
                        cells.CreateCell(row, col, value, XFindex);
                    }
                    break;

                case RecordType.FORMULA:
                    FORMULA formula = record as FORMULA;
                    cells.CreateCell(formula.RowIndex, formula.ColIndex, formula.DecodeResult(), formula.XFIndex);
                    break;
                }
            }
            return(cells);
        }
        private static CellCollection PopulateCells(List <Record> records, SharedResource sharedResource)
        {
            CellCollection cellCollection = new CellCollection();

            cellCollection.SharedResource = sharedResource;
            checked
            {
                foreach (Record current in records)
                {
                    current.Decode();
                    ushort type = current.Type;
                    if (type <= 189)
                    {
                        if (type != 6)
                        {
                            if (type == 189)
                            {
                                MULRK mULRK    = current as MULRK;
                                int   rowIndex = (int)mULRK.RowIndex;
                                for (int i = (int)mULRK.FirstColIndex; i <= (int)mULRK.LastColIndex; i++)
                                {
                                    int    index   = i - (int)mULRK.FirstColIndex;
                                    object value   = Record.DecodeRK(mULRK.RKList[index]);
                                    int    xFindex = (int)mULRK.XFList[index];
                                    cellCollection.CreateCell(rowIndex, i, value, xFindex);
                                }
                            }
                        }
                        else
                        {
                            FORMULA fORMULA = current as FORMULA;
                            cellCollection.CreateCell((int)fORMULA.RowIndex, (int)fORMULA.ColIndex, fORMULA.DecodeResult(), (int)fORMULA.XFIndex);
                        }
                    }
                    else
                    {
                        if (type != 253)
                        {
                            switch (type)
                            {
                            case 515:
                            {
                                NUMBER nUMBER = current as NUMBER;
                                cellCollection.CreateCell((int)nUMBER.RowIndex, (int)nUMBER.ColIndex, nUMBER.Value, (int)nUMBER.XFIndex);
                                break;
                            }

                            case 516:
                                break;

                            case 517:
                            {
                                BOOLERR bOOLERR = current as BOOLERR;
                                cellCollection.CreateCell((int)bOOLERR.RowIndex, (int)bOOLERR.ColIndex, bOOLERR.GetValue(), (int)bOOLERR.XFIndex);
                                break;
                            }

                            default:
                                if (type == 638)
                                {
                                    RK rK = current as RK;
                                    cellCollection.CreateCell((int)rK.RowIndex, (int)rK.ColIndex, Record.DecodeRK(rK.Value), (int)rK.XFIndex);
                                }
                                break;
                            }
                        }
                        else
                        {
                            LABELSST lABELSST = current as LABELSST;
                            Cell     cell     = cellCollection.CreateCell((int)lABELSST.RowIndex, (int)lABELSST.ColIndex, sharedResource.GetStringFromSST(lABELSST.SSTIndex), (int)lABELSST.XFIndex);
                            cell.Style.RichTextFormat = sharedResource.SharedStringTable.RichTextFormatting[lABELSST.SSTIndex];
                        }
                    }
                }
                return(cellCollection);
            }
        }