private void Report3() { CHTMLDocument ds = new CHTMLDocument(); CHTMLText txt = new CHTMLText("Trial Balance"); txt.setItalic(true); CHTMLHorizontalRule hr = new CHTMLHorizontalRule(); CHTMLInput input = new CHTMLInput(); // // // CHTMLTable table = new CHTMLTable(); table.setBorder(1); table.setCaption(new CHTMLText("TRIAL BALANCE")); CHTMLTableRow row = null; row = new CHTMLTableRow(); CHTMLTableCell cell = null; cell = new CHTMLTableCell(alignment.HEADING); cell.addObject(new CHTMLText(" Account ")); row.addObject(cell); cell = new CHTMLTableCell(alignment.HEADING); cell.addObject(new CHTMLText(" DR ")); row.addObject(cell); cell = new CHTMLTableCell(alignment.HEADING); cell.addObject(new CHTMLText(" CR ")); row.addObject(cell); row.backgroundColor = "red"; table.addObject(row); DataTable dt = TrialBalance.TrialTable(); double crTotal = 0; double drTotal = 0; foreach (DataRow dr in dt.Rows) { row = new CHTMLTableRow(); cell = new CHTMLTableCell(alignment.RIGHT); cell.addObject(new CHTMLText(dr["S_DESC"].ToString())); row.addObject(cell); cell = new CHTMLTableCell(alignment.RIGHT); double amnt = double.Parse(dr["Total"].ToString()); if (amnt >= 0) { cell.setHorizontalAlign(alignment.RIGHT); cell.addObject(new CHTMLText(amnt.ToString())); row.addObject(cell); cell = new CHTMLTableCell(alignment.RIGHT); cell.addObject(new CHTMLText(" ")); row.addObject(cell); drTotal += amnt; } else if (amnt < 0) { amnt = -amnt; cell.addObject(new CHTMLText(" ")); row.addObject(cell); cell = new CHTMLTableCell(alignment.RIGHT); cell.setHorizontalAlign(alignment.RIGHT); cell.addObject(new CHTMLText(amnt.ToString())); row.addObject(cell); crTotal += amnt; } table.addObject(row); } row = new CHTMLTableRow(); cell = new CHTMLTableCell(alignment.HEADING); cell.addObject(new CHTMLText("Total")); row.addObject(cell); cell = new CHTMLTableCell(alignment.HEADING); cell.addObject(new CHTMLText(drTotal.ToString())); row.addObject(cell); cell = new CHTMLTableCell(alignment.HEADING); cell.addObject(new CHTMLText(crTotal.ToString())); row.addObject(cell); table.addObject(row); ds.addObject(table); string rs = ds.toHTML(); FileStream fs = new FileStream(@"C:\temp\a.html", FileMode.Create); StreamWriter st = new StreamWriter(fs); st.Write(rs); st.Close(); webBrowser1.Navigate(new Uri(@"file://c:\temp\a.html")); webBrowser1.Refresh(); }