/// <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;
        }
Beispiel #2
0
        /// <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);
        }
Beispiel #3
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>
        /// 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;
        }
Beispiel #5
0
 /// <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();
 }
 /// <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();
 }
        /// <summary>
        /// Get the cell value as a rich text string (SLRstType).
        /// </summary>
        /// <param name="RowIndex">The row index.</param>
        /// <param name="ColumnIndex">The column index.</param>
        /// <returns>An SLRstType cell value.</returns>
        public SLRstType GetCellValueAsRstType(int RowIndex, int ColumnIndex)
        {
            SLRstType rst = new SLRstType(SimpleTheme.MajorLatinFont, SimpleTheme.MinorLatinFont, SimpleTheme.listThemeColors, SimpleTheme.listIndexedColors);
            int index = 0;

            if (SLTool.CheckRowColumnIndexLimit(RowIndex, ColumnIndex))
            {
                SLCellPoint pt = new SLCellPoint(RowIndex, ColumnIndex);
                if (slws.Cells.ContainsKey(pt))
                {
                    SLCell c = slws.Cells[pt];
                    if (c.CellText != null)
                    {
                        if (c.DataType == CellValues.String)
                        {
                            rst.SetText(SLTool.XmlRead(c.CellText));
                        }
                        else if (c.DataType == CellValues.SharedString)
                        {
                            try
                            {
                                index = int.Parse(c.CellText);
                                if (index >= 0 && index < listSharedString.Count)
                                {
                                    rst.FromHash(listSharedString[index]);
                                }
                                else
                                {
                                    rst.SetText(SLTool.XmlRead(c.CellText));
                                }
                            }
                            catch
                            {
                                // something terrible just happened. We'll just use whatever's in the cell...
                                rst.SetText(SLTool.XmlRead(c.CellText));
                            }
                        }
                        //else if (c.DataType == CellValues.InlineString)
                        //{
                        //    // there shouldn't be any inline strings
                        //    // because they'd already be transferred to shared strings
                        //}
                        else
                        {
                            rst.SetText(SLTool.XmlRead(c.CellText));
                        }
                    }
                    else
                    {
                        if (c.DataType == CellValues.Number)
                        {
                            rst.SetText(c.NumericValue.ToString(CultureInfo.InvariantCulture));
                        }
                        else if (c.DataType == CellValues.SharedString)
                        {
                            index = Convert.ToInt32(c.NumericValue);
                            if (index >= 0 && index < listSharedString.Count)
                            {
                                rst.FromHash(listSharedString[index]);
                            }
                            else
                            {
                                rst.SetText(SLTool.XmlRead(c.CellText));
                            }
                        }
                        else if (c.DataType == CellValues.Boolean)
                        {
                            if (c.NumericValue > 0.5) rst.SetText("TRUE");
                            else rst.SetText("FALSE");
                        }
                    }
                }
            }

            return rst.Clone();
        }