filmov
tv
How to Create Multi Style Rich Text in Excel Cell & Comment Using in EPPlus [English] - Part-12(D)

Показать описание
EPPLUS Library - Beginners Guide Part-12(D)
---------------------------------------------------------------------------
Suggested English Videos Links:
How to Add Multi Style Rich Text in Excel Cell & Comment Using ExcelRichTextCollection class in EPPlus?
-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
1) What is ExcelRichTextCollection Class?
------------------------------------------------------------------------
ExcelRichTextCollection class is a collection, containing the ExcelRichText objects.
This class belongs to OfficeOpenXml.Style namespace.
This class has five important methods, these are
--------------------------------------------------------------------------------
1) Add(String Text)
2) Insert(Integer Index, String Text)
- By using these two above methods we can add or insert ExcelRichText objects in ExcelRichTextCollection class.
3) Remove(ExcelRichText Item)
4) RemoveAt(int index)
- by using these two above methods, we can remove ExcelRichText objects by object name & Index position in ExcelRichTextCollection class.
5) Clear()
- by using this above method we can remove all ExcelRichText objects within this ExcelRichTextCollection class.
This class has three important property, these are
--------------------------------------------------------------------------------
1) Count (Read Only Property)
- It returns integer count value of how many ExcelRichText object present in a single ExcelRichTextCollection class at runtime.
2) Text (Read & Write Both)
- By using this property we are assign string text in the ExcelRichTextCollection object.
3) ExcelRichText this [int Index]
- This is a very Important property. here [int Index] is the indexer.
if you are don't know, what is index member of the class? please visit this link.
By using this property we are assigning specific ExcelRichText object by its index position.
1) How to Add Multi Style Text in Excel Cell using EPPlus?
-----------------------------------------------------------------------------------------------
ExcelRange Class has property RichText (if you are don't know, what is ExcelRange Class, please watch my previous video Part-1 first). This RichText property is the type of ExcelRichTextCollection class.
Please see this below code.
---------------------------------------------
using (ExcelRange Rng = wsSheet1.Cells["B5"])
{
Rng.Style.Font.Size = 20;
//How to add multi style text in excel cell text
ExcelRichTextCollection RichTxtCollection = Rng.RichText;
ExcelRichText RichText = RichTxtCollection.Add("H");
RichText.Color = Color.Red;
RichText.Italic = true;
//RichTxtCollection.Remove(RichText);
RichText = RichTxtCollection.Add("2");
//RichText = RichTxtCollection.Insert(1, "2");
RichText.Color = Color.Red;
RichText.Italic = true;
RichText.VerticalAlign = ExcelVerticalAlignmentFont.Subscript;
RichText = RichTxtCollection.Add("O");
RichText.Color = Color.Red;
RichText.Italic = false;
RichText = RichTxtCollection.Add(" & ");
RichText.Color = Color.Black;
RichText.Italic = false;
RichText = RichTxtCollection.Add("E=MC");
RichText.Color = Color.Blue;
RichText.Italic = false;
RichText = RichTxtCollection.Add("2");
RichText.Color = Color.Blue;
RichText.Italic = false;
RichText.VerticalAlign = ExcelVerticalAlignmentFont.Superscript;
//RichTxtCollection.Clear();
}
Thank you for watching this video.
Please subscribe my YouTube Channel & don't forget to like and share.
---------------------------------------------------------------------------
Suggested English Videos Links:
How to Add Multi Style Rich Text in Excel Cell & Comment Using ExcelRichTextCollection class in EPPlus?
-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
1) What is ExcelRichTextCollection Class?
------------------------------------------------------------------------
ExcelRichTextCollection class is a collection, containing the ExcelRichText objects.
This class belongs to OfficeOpenXml.Style namespace.
This class has five important methods, these are
--------------------------------------------------------------------------------
1) Add(String Text)
2) Insert(Integer Index, String Text)
- By using these two above methods we can add or insert ExcelRichText objects in ExcelRichTextCollection class.
3) Remove(ExcelRichText Item)
4) RemoveAt(int index)
- by using these two above methods, we can remove ExcelRichText objects by object name & Index position in ExcelRichTextCollection class.
5) Clear()
- by using this above method we can remove all ExcelRichText objects within this ExcelRichTextCollection class.
This class has three important property, these are
--------------------------------------------------------------------------------
1) Count (Read Only Property)
- It returns integer count value of how many ExcelRichText object present in a single ExcelRichTextCollection class at runtime.
2) Text (Read & Write Both)
- By using this property we are assign string text in the ExcelRichTextCollection object.
3) ExcelRichText this [int Index]
- This is a very Important property. here [int Index] is the indexer.
if you are don't know, what is index member of the class? please visit this link.
By using this property we are assigning specific ExcelRichText object by its index position.
1) How to Add Multi Style Text in Excel Cell using EPPlus?
-----------------------------------------------------------------------------------------------
ExcelRange Class has property RichText (if you are don't know, what is ExcelRange Class, please watch my previous video Part-1 first). This RichText property is the type of ExcelRichTextCollection class.
Please see this below code.
---------------------------------------------
using (ExcelRange Rng = wsSheet1.Cells["B5"])
{
Rng.Style.Font.Size = 20;
//How to add multi style text in excel cell text
ExcelRichTextCollection RichTxtCollection = Rng.RichText;
ExcelRichText RichText = RichTxtCollection.Add("H");
RichText.Color = Color.Red;
RichText.Italic = true;
//RichTxtCollection.Remove(RichText);
RichText = RichTxtCollection.Add("2");
//RichText = RichTxtCollection.Insert(1, "2");
RichText.Color = Color.Red;
RichText.Italic = true;
RichText.VerticalAlign = ExcelVerticalAlignmentFont.Subscript;
RichText = RichTxtCollection.Add("O");
RichText.Color = Color.Red;
RichText.Italic = false;
RichText = RichTxtCollection.Add(" & ");
RichText.Color = Color.Black;
RichText.Italic = false;
RichText = RichTxtCollection.Add("E=MC");
RichText.Color = Color.Blue;
RichText.Italic = false;
RichText = RichTxtCollection.Add("2");
RichText.Color = Color.Blue;
RichText.Italic = false;
RichText.VerticalAlign = ExcelVerticalAlignmentFont.Superscript;
//RichTxtCollection.Clear();
}
Thank you for watching this video.
Please subscribe my YouTube Channel & don't forget to like and share.