string sFlag = "Error"; StreamWriter sw = new StreamWriter(filepath, false); StringBuilder dataToExport = new StringBuilder(); sw.WriteLine(Convert.ToString(dataToExport)); try { if (filename.Trim() != "" && filepath != "" && dtResult.Rows.Count != 0) { dataToExport.Append("<table width=\"100%\">"); dataToExport.Append("<tr>"); dataToExport.Append("<td style=\"height:120px; width:306px;\"> Cybex Exim Solutions (P) Ltd."); dataToExport.Append("<br/>xyz,<br />abc "); dataToExport.Append("<br/>Tel: 123456789; Fax: 123456789"); dataToExport.Append("<br/>Email:xyz@abc.com, Web:- www.my.com"); dataToExport.Append("</td>"); dataToExport.Append("</tr>"); dataToExport.Append("<tr>"); foreach (DataColumn dCol in dtResult.Columns) { { dataToExport.Append("<td style=\"border:solid 1px black; background-color:orange;\">"); dataToExport.Append(HttpContext.Current.Server.HtmlEncode(dCol.ColumnName)); dataToExport.Append("</td>"); } dataToExport.Append("</tr>"); foreach (DataRow dRow in dtResult.Rows) { dataToExport.Append("<tr>"); foreach (object obj in dRow.ItemArray) { dataToExport.Append("<td style=border:solid 1px blue;>"); dataToExport.Append(HttpContext.Current.Server.HtmlEncode(obj.ToString())); dataToExport.Append("</td>"); } dataToExport.Append("</tr>"); } dataToExport.Append("</table>"); } sw.WriteLine(Convert.ToString(dataToExport)); sFlag = "Success"; sw.Close();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)