1

I add dynamic row in DataTable.I need to bold the "Total" in Bold.How to do this?

DataTable dt = new DataTable();
dt.Rows.Add(new object[] { "", "Total", "valuehere"});
User
  • 1,644
  • 10
  • 40
  • 64
  • 1
    You are not going to display datatable,then why to make it bold,can you elaborate what exactly you want to do? – Anand Oct 21 '13 at 05:50
  • @Anand is right could you explain what do you want to do? You want in to display on a datagrid? Wpf/Forms? Some more code? – Tafari Oct 21 '13 at 05:53
  • @Anand my aim is I get the data in Datatable from sql.And I export the table into excel.In that excel sheet,I want to display total as bold font – User Oct 21 '13 at 06:04
  • Maybe try formatting the excel file? Never done it myself, but maybe something like: `Range("A:A").FontWeight = 700 'bold` would bold column A in Excel? – Tafari Oct 21 '13 at 06:12
  • http://stackoverflow.com/questions/16187125/make-a-text-in-a-particular-cell-bold-in-exported-excel-sheet-windows-c-sharp?answertab=active#tab-top – C Sharper Oct 21 '13 at 06:15

2 Answers2

0

Typically text formatting is done wherever the code for displaying the text is. A string does not contain that sort of formatting information usually.

0

Carlos is right.

At the max you can try getting your text from database with tag as follows, which might help you.

DataTable dt = new DataTable();
dt.Rows.Add(new object[] { "", "<b>Total", "<b>valuehere"});

You can bold the Object in which you are displaying this datatable values.

Eg. Label, gridviewcells,etc

C Sharper
  • 8,284
  • 26
  • 88
  • 151
  • http://www.codeproject.com/Tips/406704/Export-DataTable-to-Excel-with-Formatting-in-Cshar – C Sharper Oct 21 '13 at 06:13
  • http://stackoverflow.com/questions/16187125/make-a-text-in-a-particular-cell-bold-in-exported-excel-sheet-windows-c-sharp?answertab=active#tab-top – C Sharper Oct 21 '13 at 06:14