We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Html content not fully converting to Excel using Aspose.Cells

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.

Hi,


Thanks for providing us template file, sample code and screen shot.

After an initial test, I observed the issue as you mentioned by using your sample code with your template HTML file. I found that HTML contents are not fully converted to Excel using Aspose.Cells APIs as per your attached screenshot (Green boundary denotes which I am not able to get through the above code in excel file)
e.g
Sample code:

Stream receiveStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(htmlString));

HTMLLoadOptions options = new HTMLLoadOptions(LoadFormat.Html);
Workbook book = new Workbook(receiveStream, options);
book.Worksheets[0].AutoFitColumns();
book.Worksheets[0].IsGridlinesVisible = true;
book.Save(“out1.xls”, SaveFormat.Excel97To2003);

I have logged a ticket with an id “CELLSNET-44159” for your issue. We will look into it soon.

Once we have any update on it, we will let you know here.

Thank you.