Esempio n. 1
0
        private void buttonReadFile_Click(object sender, EventArgs e)
        {
            string fileName = textBoxReadFile.Text;

            if (!File.Exists(fileName))
            {
                MessageBox.Show(string.Format("{0} not found!", fileName));
                return;
            }
            XlsDocument   xls     = new XlsDocument(fileName);
            Bytes         stream  = xls.OLEDoc.Streams[xls.OLEDoc.Streams.GetIndex(org.in2bits.MyOle2.Directory.Biff8Workbook)].Bytes;
            List <Record> records = Record.GetAll(stream);
            StringBuilder sb      = new StringBuilder();

            foreach (Record record in records)
            {
                string name = RID.Name(record.RID);
                sb.Append(name);
                sb.Append(new string(' ', RID.NAME_MAX_LENGTH - name.Length) + ": ");
                byte[] recordData = record.Data.ByteArray;
                for (int i = 0; i < recordData.Length; i++)
                {
                    if (i > 0)
                    {
                        sb.Append(" ");
                    }
                    sb.Append(string.Format("{0:x2}", recordData[i]));
                }
                sb.Append(Environment.NewLine);
            }
            richTextBoxRecordList.Text = sb.ToString();
        }
Esempio n. 2
0
        private static void WriteRecordsToFile(Bytes bytes, string fileName)
        {
            FileInfo      fi  = new FileInfo(fileName);
            FileStream    fs  = fi.Open(FileMode.Create, FileAccess.Write);
            int           pos = 0;
            StringBuilder sb  = new StringBuilder();

            while (pos < bytes.Length)
            {
                byte[] ridArray = bytes.Get(pos, 2).ByteArray;
                sb.Append(RID.Name(ridArray));
                sb.Append(" ");
                pos += 2;
                ushort len = BitConverter.ToUInt16(bytes.Get(pos, 2).ByteArray, 0);
                pos += 2;
                byte[] byteArray = bytes.Get(pos, len).ByteArray;
                foreach (byte b in byteArray)
                {
                    sb.Append(GetByteHex(b));
                    sb.Append(" ");
                }
                sb.Append(Environment.NewLine);
                pos += byteArray.Length;
            }
            string records = sb.ToString();

            fs.Write(Encoding.ASCII.GetBytes(records), 0, records.Length);
            fs.Flush();
            fs.Close();
        }
Esempio n. 3
0
 public void GetNameFromByteArray()
 {
     byte[] tableOpDifferentInstance = new byte[] { 0x36, 0x02 };
     byte[] tableOp = RID.TABLEOP;
     Assert.AreEqual("TABLEOP", RID.Name(tableOp), "RID name");
     Assert.AreEqual("TABLEOP", RID.Name(tableOpDifferentInstance), "RID name");
 }
Esempio n. 4
0
        // Token: 0x0600006C RID: 108 RVA: 0x000045AC File Offset: 0x000035AC
        internal static byte[] ByteArray(byte[] rid)
        {
            string key = RID.Name(rid);

            if (RID._rids.ContainsKey(key))
            {
                return(RID._rids[key]);
            }
            return(rid);
        }
Esempio n. 5
0
 internal void SetValue(byte[] rid, Bytes data)
 {
     if (rid == RID.RK)
     {
         DecodeRK(data);
     }
     else if (rid == RID.LABEL)
     {
         DecodeLABEL(data);
     }
     else if (rid == RID.LABELSST)
     {
         DecodeLABELSST(data);
     }
     else if (rid == RID.NUMBER)
     {
         DecodeNUMBER(data);
     }
     else
     {
         throw new ApplicationException(string.Format("Unsupported RID {0}", RID.Name(rid)));
     }
 }