GemBox电子表格:一个单元格中有多种字体颜色

时间:2012-10-09 08:18:16

标签: excel fonts spreadsheet gembox-spreadsheet

我正在使用GemBox Spreadsheet导出数据,我需要将单元格中的文本格式化为多种颜色。

在Excel中可以这样(在StackOverflow上找到):

Dim fixedLength As Long
  fixedLength = Len("Employee")
  ActiveCell.FormulaR1C1 = "Employee Some Employee"
  With ActiveCell.Characters(Start:=fixedLength + 2, Length:=Len(ActiveCell) - FixedLength - 1).Font
    .Color = vbRed
  End With

但是,我在GemBox类中找到的只是设置Style.Font.Color属性,这会影响整个单元格。 例如:

for (int i = 0; i < tempArray.GetUpperBound(0); i++)
{
  Color backColour = ColorTranslator.FromHtml(tempArray[i+1]);
  ws.Cells[row, col].Value += tempArray[i] + Environment.NewLine;
  ws.Cells[row, col].Style.Font.Color = backColour;
  i++;
}

这可以用GemBox吗?

适用于.NET4.0的GemBox Spreadsheet Professional 3.5

v4.0.30319

v35.3.40.1000

2 个答案:

答案 0 :(得分:0)

我知道这个问题很老,但几年前我通过电子邮件询问了开发人员。他们说这不可用。

如果您直接向他们发送电子邮件,他们通常会在一个工作日内回复。我认为他们在捷克共和国。

您可以在此处打开支持服务单:http://www.gemboxsoftware.com/support-center/new-ticket?newticket[ticket][department_id]=1&newticket[ticket][product_id]=1

同一页面上还有一个反馈标签,您可以建议将其添加为功能,其他开发者可以对要添加的功能进行投票。

答案 1 :(得分:0)

当前版本的GemBox.Spreadsheet(版本3.9)具有API支持。请参阅以下内联文本格式演示示例:

http://www.gemboxsoftware.com/SampleExplorer/Spreadsheet/BasicFeatures/InlineTextFormatting?tab=cs

简而言之,您需要使用GetCharacters方法:

http://www.gemboxsoftware.com/spreadsheet/help/html/Overload_GemBox_Spreadsheet_AbstractRange_GetCharacters.htm

此方法返回单元格文本中的一系列字符,然后您可以根据需要进行格式化。

相关问题