Hi I have a requirement to show some reports for which I have created a generic function and I am passing the views html to the function so that I could write it to an excel file. using Aspose.cells I am near to goal. A small issue I am not able to identify. Require help.
Following is the c# code
public override void ExecuteResult()
{
//Create a response stream to create and write the Excel file
HttpContext curContext = HttpContext.Current;
curContext.Response.Clear();
curContext.Response.AddHeader(“content-disposition”, “attachment;filename=” + fileName);
curContext.Response.Charset = “”;
curContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
curContext.Response.ContentType = “application/ms-excel”;
Stream receiveStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(ExcelGridView));//Here I pass my html content
HTMLLoadOptions options = new HTMLLoadOptions(LoadFormat.Html);
//Load the Html file through file path while passing the instance of HTMLLoadOptions class
Workbook book = new Workbook(receiveStream, options);
book.Worksheets[0].AutoFitColumns();
book.Worksheets[0].IsGridlinesVisible = true;
License license = new License(); //pass Aspose License file
license.SetLicense(“Aspose.Total.lic”);
MemoryStream ms = new MemoryStream();
book.Save(ms, SaveFormat.Excel97To2003);
//Write the stream back to the response
curContext.Response.ContentEncoding = System.Text.Encoding.Unicode;
curContext.Response.BinaryWrite(ms.ToArray()); //Write(sr.ReadToEnd());
curContext.Response.End();
}
Html content file I have attached
Also I have attached an image of the table generated from html content
Blue boundary denotes the whole html
Green boundary denotes which I am not able to get through the above code in excel file
Red color boundary denotes what i am able to get in the excel from above code.
I am not sure what I have done wrong which has resulted in this wrong output any help in this will be really appreciated.