2017-01-16 71 views

回答

0

的SpreadsheetGear不支持解析和渲染HTML。如果您將這種類型的內容放入單元格中,則會顯示原始標記。

的SpreadsheetGear不支持添加富文本(RTF)的細胞,但你需要使用的SpreadsheetGear API使用要做到這一點:

下面的例子將呈現類似這樣:

Rendered rich-text formatting from sample code

// Create new workbook. 
IWorkbook workbook = Factory.GetWorkbook(); 
IWorksheet worksheet = workbook.ActiveWorksheet; 
IRange cells = worksheet.Cells; 

// Add text to A1 which we'll format below... 
cells["A1"].Value = "This Is My Header\n\nHello World!"; 

// Format "header" as bold and with a larger font size. 
ICharacters charsHeader = cells["A1"].GetCharacters(0, 17); 
charsHeader.Font.Bold = true; 
charsHeader.Font.Size = 18; 

// Format "Hello" text. 
ICharacters charsHello = cells["A1"].GetCharacters(19, 5); 
charsHello.Font.Italic = true; 
charsHello.Font.Color = SpreadsheetGear.Colors.DarkRed; 

// Format "World" text. 
ICharacters charsWorld = cells["A1"].GetCharacters(25, 5); 
charsWorld.Font.Underline = UnderlineStyle.Single; 
charsWorld.Font.Color = SpreadsheetGear.Colors.DarkBlue; 

// Expand column width to accommodate header text 
cells["A:A"].ColumnWidth = 30; 

// Save and view in Excel... 
workbook.SaveAs(@"c:\temp\rtf.xlsx", FileFormat.OpenXMLWorkbook); 

// ...or attach to SpreadsheetGear's WPF WorkbookView to 
// confirm RTF is displaying as expected (NOTE: the WinForms 
// WorkbookView does not support rendering RTF). 
workbookView.ActiveWorkbook = workbook; 
相關問題