We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Formatting select characters in cells

Hello, In the past, using automation I would sometimes need to format certain characters in a cell. Here''s an example of what I''m talking about written in Delphi using automation: ---- if Trim(dsCamra.FieldByName (''Tran_Type'').AsString) = ''BUY'' then ExcelWorksheet.Range [''A'' + IntToStr(intCurrentRow), ''A'' + IntToStr(intCurrentRow)].Value := ''WE HAVE PURCHASED THROUGH:'' ... if Trim(dsCamra.FieldByName (''Tran_Type'').AsString) = ''BUY'' then ExcelWorksheet.Range [''A'' + IntToStr(intCurrentRow), ''A'' + IntToStr(intCurrentRow)].Characters [9, 9].Font.Bold := True ----- As you can see, the word ''PURCHASED'' is set to bold. Is there a way to drill down to the characters level of a certain cell? If not, what would the best way be to do this? Would RichText be the answer? Thanks!

1 Reply

AD Administrator Syncfusion Team February 9, 2005 03:25 PM UTC

Hi Shannon, Yes, you are correct in suggesting that RichText is the solution. Here is a sample code snippet IRange range = mySheet.Range["A1"]; range.Text = "Hello"; IRichTextString rtf = range.RichText; IFont font = myWorkbook.CreateFont(); font.Bold = true; font.Italic = true; font.RGBColor = Color.Red; rtf.SetFont( 2, 3, font ); However, there seems to be a bug in version 3.0 in applying the RichText.[It works fine in version 2.1.0.9]. We will fix it and post and update within the next few days. Could you please open a Direc-Trac incident regarding this. Thanks, Stephen. >Hello, >In the past, using automation I would sometimes need to format certain characters in a cell. Here''s an example of what I''m talking about written in Delphi using automation: >---- >if Trim(dsCamra.FieldByName (''Tran_Type'').AsString) = ''BUY'' then > ExcelWorksheet.Range [''A'' + IntToStr(intCurrentRow), > ''A'' + IntToStr(intCurrentRow)].Value := ''WE HAVE PURCHASED THROUGH:'' >... >if Trim(dsCamra.FieldByName (''Tran_Type'').AsString) = ''BUY'' then > ExcelWorksheet.Range [''A'' + IntToStr(intCurrentRow), > ''A'' + IntToStr(intCurrentRow)].Characters [9, 9].Font.Bold := True >----- >As you can see, the word ''PURCHASED'' is set to bold. > >Is there a way to drill down to the characters level of a certain cell? If not, what would the best way be to do this? Would RichText be the answer? > >Thanks!

Loader.
Live Chat Icon For mobile
Up arrow icon