How to export the as excel without excel
public static void ExportToExcel(List MailBoxData)
{
try
{
StringBuilder strHTMLBuilder = new StringBuilder();
strHTMLBuilder.Append("");
strHTMLBuilder.Append("");
strHTMLBuilder.Append("
"); strHTMLBuilder.Append("");
strHTMLBuilder.Append("");
strHTMLBuilder.Append("");
strHTMLBuilder.Append("MailId Size KB Size GB ");
strHTMLBuilder.Append("
");
foreach (var column in MailBoxData)
{
strHTMLBuilder.Append("");
strHTMLBuilder.Append("");
strHTMLBuilder.Append(column.MailId);
strHTMLBuilder.Append("
"); strHTMLBuilder.Append("");
strHTMLBuilder.Append(column.MailSize);
strHTMLBuilder.Append("
"); strHTMLBuilder.Append("");
strHTMLBuilder.Append(column.MailSize/1024/1024);
strHTMLBuilder.Append("
"); strHTMLBuilder.Append("
"); }
strHTMLBuilder.Append("
"); strHTMLBuilder.Append("
"); strHTMLBuilder.Append("
"); string outPutPath = ConfigurationManager.AppSettings["ExcelOutPutPath"];
string sheetName = "Email_InBox_Space" + "_" + DateTime.Now.ToString("dd_M_yyyy_HH_mm_ss") + ".xls";
if (!Directory.Exists(@outPutPath))
Directory.CreateDirectory(@outPutPath);
System.IO.File.WriteAllText((@outPutPath + sheetName), strHTMLBuilder.ToString());
}
catch (System.Exception OExp)
{
Console.WriteLine("ReadWorkViewNAMailSupport Exception" + OExp.Message);
}
}
{
try
{
StringBuilder strHTMLBuilder = new StringBuilder();
strHTMLBuilder.Append("");
strHTMLBuilder.Append("");
strHTMLBuilder.Append("
"); strHTMLBuilder.Append("");
strHTMLBuilder.Append("
strHTMLBuilder.Append("
strHTMLBuilder.Append("
strHTMLBuilder.Append("
");
foreach (var column in MailBoxData)
{
strHTMLBuilder.Append("
strHTMLBuilder.Append("
strHTMLBuilder.Append(column.MailId);
strHTMLBuilder.Append("
"); strHTMLBuilder.Append("
strHTMLBuilder.Append(column.MailSize);
strHTMLBuilder.Append("
"); strHTMLBuilder.Append("
strHTMLBuilder.Append(column.MailSize/1024/1024);
strHTMLBuilder.Append("
"); strHTMLBuilder.Append("
"); }
strHTMLBuilder.Append("
"); strHTMLBuilder.Append("
"); strHTMLBuilder.Append("
"); string outPutPath = ConfigurationManager.AppSettings["ExcelOutPutPath"];
string sheetName = "Email_InBox_Space" + "_" + DateTime.Now.ToString("dd_M_yyyy_HH_mm_ss") + ".xls";
if (!Directory.Exists(@outPutPath))
Directory.CreateDirectory(@outPutPath);
System.IO.File.WriteAllText((@outPutPath + sheetName), strHTMLBuilder.ToString());
}
catch (System.Exception OExp)
{
Console.WriteLine("ReadWorkViewNAMailSupport Exception" + OExp.Message);
}
}
Comments