Exemplo n.º 1
0
        public byte[] ToDataEntryBytes()
        {
            var __buffer = new ExcelTranslatorBuffer();

            __buffer.Reset();

            //写入表格的行列数
            __buffer.In(sheetName);
            __buffer.In(nRow);
            __buffer.In(nColu);

            //属性写入字节流
            for (int i = 0; i < nColu; i++)
            {
                __buffer.In(mAttriNames[i]);
                __buffer.In((int)mAttriTypes[i]);
            }
            //遍历所有的数据行,写入字节流
            for (int i = 0; i < nRow; i++)
            {
                for (int j = 0; j < nColu; j++)
                {
                    __buffer.In(mAttriTypes[j], mCellValues[i, j]);
                }
            }
            byte[] __bytes = new byte[__buffer.Size];
            Array.Copy(__buffer.GetBuffer(), __bytes, __buffer.Size);
            return(__bytes);
        }
Exemplo n.º 2
0
        /// <summary>
        /// bytes字节 转换为Table
        /// </summary>
        public TranslatorTable(byte[] bytes)
        {
            var __temp_buff = new ExcelTranslatorBuffer(bytes, (UInt32)bytes.Length);

            //写读出格的行列数
            __temp_buff.Out(out sheetName);
            __temp_buff.Out(out nRow);
            __temp_buff.Out(out nColu);

            //读取属性字段 和属性数据类型
            mAttriNames = new string[nColu];
            mAttriTypes = new ValueType[nColu];
            for (int index_c = 0; index_c < nColu; index_c++)
            {
                string attr_name = string.Empty;
                __temp_buff.Out(out attr_name);
                mAttriNames[index_c] = attr_name;

                int attr_type = 0;
                __temp_buff.Out(out attr_type);
                mAttriTypes[index_c] = (ValueType)attr_type;
            }

            //读取数据
            mIds        = new string[nRow];
            mCellValues = new List <byte[]> [nRow, nColu];
            for (int index_r = 0; index_r < nRow; index_r++)
            {
                for (int index_c = 0; index_c < nColu; index_c++)
                {
                    List <byte[]> value;
                    __temp_buff.Out(mAttriTypes[index_c], out value);
                    mCellValues[index_r, index_c] = value;
                }
                mIds[index_r] = UTF8Encoding.UTF8.GetString(mCellValues[index_r, 0][0]);
            }
        }
 public ExcelTranslatorBuffer(ExcelTranslatorBuffer r)
 {
     m_validateSize = m_rpos = m_wpos = 0;
     Resize(r.m_validateSize);
 }
Exemplo n.º 4
0
 public abstract void DeSerialized(ExcelTranslatorBuffer buffer);