简体   繁体   中英

Import Rich Text Data From Excel Sheet Using c#

I want to import data from excel sheet with richtext ie font family

But I can get only bold and italic style using below given code

Microsoft.Office.Interop.Excel.Range Range = (Microsoft.Office.Interop.Excel.Range)Cell;
    int TextLength = Range.Text.ToString().Length;
    for (int CharCount = 1; CharCount <= TextLength; CharCount++)
    {
        Microsoft.Office.Interop.Excel.Characters charToTest = Range.get_Characters(CharCount, 1);
        bool IsBold = (bool)charToTest.Font.Bold;
        bool IsItalic = (bool)charToTest.Font.Italic;
        // other formatting tests here
    }

Can anybody help me to get the rich text data from Excel Sheet using Interop or any other method in c#.net

Thanks in advance

How about:

Range someRange = activeWorksheet.Range["A1", "A1"];
var fontFamily = someRange.Font.Name;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM