/// <summary>
        /// Get existing shared strings. WARNING: This is only a snapshot. Any changes made to the returned result are not used.
        /// </summary>
        /// <returns>A list of existing shared strings.</returns>
        public List <SLRstType> GetSharedStrings()
        {
            List <SLRstType> result = new List <SLRstType>();
            SLRstType        rst    = new SLRstType();

            for (int i = 0; i < listSharedString.Count; ++i)
            {
                rst.FromHash(listSharedString[i]);
                result.Add(rst.Clone());
            }

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Get existing comments in the currently selected worksheet. WARNING: This is only a snapshot. Any changes made to the returned result are not used.
        /// </summary>
        /// <returns>A Dictionary of existing comments.</returns>
        public Dictionary <SLCellPoint, SLRstType> GetCommentText()
        {
            Dictionary <SLCellPoint, SLRstType> result = new Dictionary <SLCellPoint, SLRstType>();

            // we don't add to existing comments, so it's either get existing comments
            // or use the newly inserted comments.
            if (!string.IsNullOrEmpty(gsSelectedWorksheetRelationshipID))
            {
                WorksheetPart wsp = (WorksheetPart)wbp.GetPartById(gsSelectedWorksheetRelationshipID);
                if (wsp.WorksheetCommentsPart != null)
                {
                    Comment   comm;
                    int       iRowIndex, iColumnIndex;
                    SLRstType rst = new SLRstType();
                    using (OpenXmlReader oxr = OpenXmlReader.Create(wsp.WorksheetCommentsPart.Comments.CommentList))
                    {
                        while (oxr.Read())
                        {
                            if (oxr.ElementType == typeof(Comment))
                            {
                                comm = (Comment)oxr.LoadCurrentElement();
                                SLTool.FormatCellReferenceToRowColumnIndex(comm.Reference.Value, out iRowIndex, out iColumnIndex);
                                rst.FromCommentText(comm.CommentText);
                                result[new SLCellPoint(iRowIndex, iColumnIndex)] = rst.Clone();
                            }
                        }
                    }
                }
                else
                {
                    List <SLCellPoint> pts = slws.Comments.Keys.ToList <SLCellPoint>();
                    foreach (SLCellPoint pt in pts)
                    {
                        result[pt] = slws.Comments[pt].rst.Clone();
                    }
                }
            }

            return(result);
        }
 /// <summary>
 /// Set the comment text given rich text content.
 /// </summary>
 /// <param name="RichText">The rich text content</param>
 public void SetText(SLRstType RichText)
 {
     this.rst = new SLRstType();
     this.rst = RichText.Clone();
 }