Exemplo n.º 1
0
 public void ReadFrom(Stream is1)
 {
     try
     {
         int         cnt = 0;
         XmlDocument xml = ConvertStreamToXml(is1);
         _sstDoc = SstDocument.Parse(xml, NamespaceManager);
         CT_Sst sst = _sstDoc.GetSst();
         count       = (int)sst.count;
         uniqueCount = (int)sst.uniqueCount;
         foreach (CT_Rst st in sst.si)
         {
             string key = GetKey(st);
             if (key != null && !stmap.ContainsKey(key))
             {
                 stmap.Add(key, cnt);
             }
             strings.Add(st);
             cnt++;
         }
     }
     catch (XmlException e)
     {
         throw new IOException("unable to parse shared strings table", e);
     }
 }
Exemplo n.º 2
0
        private void WriteSharedStrings()
        {
            var rest = new List <CT_Rst>();

            foreach (var s in sharedStrings)
            {
                rest.Add(new CT_Rst
                {
                    t     = s,
                    Space = s.StartsWith(" ") || s.EndsWith(" ") ? "preserve" : null
                });
            }
            CT_Sst sst = new CT_Sst()
            {
                si = rest.ToArray()
            };
            var relativePath = "sharedStrings.xml";
            var path         = "xl/" + relativePath;

            WriteFile(path, sst, SpreadsheetNs(false));
            workbookRelationships.Add(new CT_Relationship {
                Type = Relationships.SharedStrings, Target = relativePath
            });
            OverrideContentType(path, ContentTypes.SharedStrings);
        }
Exemplo n.º 3
0
 public void ReadFrom(Stream is1)
 {
     try
     {
         int cnt = 0;
         _sstDoc = SstDocument.Parse(is1);
         CT_Sst sst = _sstDoc.GetSst();
         count       = (int)sst.count;
         uniqueCount = (int)sst.uniqueCount;
         foreach (CT_Rst st in sst.si)
         {
             string key = GetKey(st);
             if (key != null && !stmap.ContainsKey(key))
             {
                 stmap.Add(key, cnt);
             }
             strings.Add(st);
             cnt++;
         }
     }
     catch (XmlException e)
     {
         throw new IOException(e.Message);
     }
 }
Exemplo n.º 4
0
 public void ReadFrom(Stream is1)
 {
     try
     {
         int num = 0;
         this._sstDoc = SstDocument.Parse(is1);
         CT_Sst sst = this._sstDoc.GetSst();
         this.count       = sst.count;
         this.uniqueCount = sst.uniqueCount;
         foreach (CT_Rst st in sst.si)
         {
             string key = this.GetKey(st);
             if (key != null && !this.stmap.ContainsKey(key))
             {
                 this.stmap.Add(key, num);
             }
             this.strings.Add(st);
             ++num;
         }
     }
     catch (XmlException ex)
     {
         throw new IOException(ex.Message);
     }
 }
Exemplo n.º 5
0
        public void WriteTo(Stream out1)
        {
            CT_Sst sst = this._sstDoc.GetSst();

            sst.count                = this.count;
            sst.countSpecified       = true;
            sst.uniqueCount          = this.uniqueCount;
            sst.uniqueCountSpecified = true;
            this._sstDoc.Save(out1);
        }
Exemplo n.º 6
0
        /**
         *
         * this table out as XML.
         *
         * @param out The stream to write to.
         * @throws IOException if an error occurs while writing.
         */
        public void WriteTo(Stream out1)
        {
            // the following two lines turn off writing CDATA
            // see Bugzilla 48936
            //options.SetSaveCDataLengthThreshold(1000000);
            //options.SetSaveCDataEntityCountThreshold(-1);
            CT_Sst sst = _sstDoc.GetSst();

            sst.count       = count;
            sst.uniqueCount = uniqueCount;

            //re-create the sst table every time saving a workbook
            _sstDoc.Save(out1);
        }
Exemplo n.º 7
0
        public void ReadFrom(XmlDocument xml)
        {
            int cnt = 0;

            _sstDoc = SstDocument.Parse(xml, NamespaceManager);
            CT_Sst sst = _sstDoc.GetSst();

            count       = (int)sst.count;
            uniqueCount = (int)sst.uniqueCount;
            foreach (CT_Rst st in sst.si)
            {
                string key = GetKey(st);
                if (key != null && !stmap.ContainsKey(key))
                {
                    stmap.Add(key, cnt);
                }
                strings.Add(st);
                cnt++;
            }
        }